2626import org .apache .doris .common .Config ;
2727import org .apache .doris .common .ErrorCode ;
2828import org .apache .doris .common .ErrorReport ;
29- import org .apache .doris .common .FeConstants ;
3029import org .apache .doris .common .InternalErrorCode ;
3130import org .apache .doris .common .Pair ;
3231import org .apache .doris .common .UserException ;
@@ -210,6 +209,11 @@ private void initSourceJob() {
210209 init ();
211210 checkRequiredSourceProperties ();
212211 List <String > createTbls = createTableIfNotExists ();
212+ if (sourceProperties .get (DataSourceConfigKeys .INCLUDE_TABLES ) == null ) {
213+ // cdc need the final includeTables
214+ String includeTables = String .join ("," , createTbls );
215+ sourceProperties .put (DataSourceConfigKeys .INCLUDE_TABLES , includeTables );
216+ }
213217 this .offsetProvider = new JdbcSourceOffsetProvider (getJobId (), dataSourceType , sourceProperties );
214218 JdbcSourceOffsetProvider rdsOffsetProvider = (JdbcSourceOffsetProvider ) this .offsetProvider ;
215219 rdsOffsetProvider .splitChunks (createTbls );
@@ -232,9 +236,6 @@ private void checkRequiredSourceProperties() {
232236 "password is required property" );
233237 Preconditions .checkArgument (sourceProperties .get (DataSourceConfigKeys .DATABASE ) != null ,
234238 "database is required property" );
235- Preconditions .checkArgument (sourceProperties .get (DataSourceConfigKeys .INCLUDE_TABLES ) != null
236- || sourceProperties .get (DataSourceConfigKeys .EXCLUDE_TABLES ) != null ,
237- "Either include_tables or exclude_tables must be specified" );
238239 if (!sourceProperties .containsKey (DataSourceConfigKeys .OFFSET )) {
239240 sourceProperties .put (DataSourceConfigKeys .OFFSET , DataSourceConfigKeys .OFFSET_LATEST );
240241 }
@@ -515,6 +516,7 @@ protected void fetchMeta() {
515516 offsetProvider .fetchRemoteMeta (new HashMap <>());
516517 }
517518 } catch (Exception ex ) {
519+ //todo: The job status = MANUAL_PAUSE_ERR, No need to set failureReason again
518520 log .warn ("fetch remote meta failed, job id: {}" , getJobId (), ex );
519521 failureReason = new FailureReason (InternalErrorCode .GET_REMOTE_DATA_ERROR ,
520522 "Failed to fetch meta, " + ex .getMessage ());
@@ -572,6 +574,7 @@ public void onStreamTaskFail(AbstractStreamingTask task) throws JobException {
572574
573575 public void onStreamTaskSuccess (AbstractStreamingTask task ) {
574576 try {
577+ resetFailureInfo (null );
575578 succeedTaskCount .incrementAndGet ();
576579 Env .getCurrentEnv ().getJobManager ().getStreamingTaskManager ().removeRunningTask (task );
577580 AbstractStreamingTask nextTask = createStreamingTask ();
@@ -729,7 +732,7 @@ public TRow getTvfInfo() {
729732 trow .addToColumnValue (new TCell ().setStringVal (getJobName ()));
730733 trow .addToColumnValue (new TCell ().setStringVal (getCreateUser ().getQualifiedUser ()));
731734 trow .addToColumnValue (new TCell ().setStringVal (getJobConfig ().getExecuteType ().name ()));
732- trow .addToColumnValue (new TCell ().setStringVal (FeConstants . null_string ));
735+ trow .addToColumnValue (new TCell ().setStringVal ("" ));
733736 trow .addToColumnValue (new TCell ().setStringVal (getJobStatus ().name ()));
734737 trow .addToColumnValue (new TCell ().setStringVal (getShowSQL ()));
735738 trow .addToColumnValue (new TCell ().setStringVal (TimeUtils .longToTimeString (getCreateTimeMs ())));
@@ -738,30 +741,30 @@ public TRow getTvfInfo() {
738741 trow .addToColumnValue (new TCell ().setStringVal (String .valueOf (getCanceledTaskCount ().get ())));
739742 trow .addToColumnValue (new TCell ().setStringVal (getComment ()));
740743 trow .addToColumnValue (new TCell ().setStringVal (properties != null && !properties .isEmpty ()
741- ? GsonUtils .GSON .toJson (properties ) : FeConstants . null_string ));
744+ ? GsonUtils .GSON .toJson (properties ) : "" ));
742745
743746 if (offsetProvider != null && StringUtils .isNotEmpty (offsetProvider .getShowCurrentOffset ())) {
744747 trow .addToColumnValue (new TCell ().setStringVal (offsetProvider .getShowCurrentOffset ()));
745748 } else {
746- trow .addToColumnValue (new TCell ().setStringVal (FeConstants . null_string ));
749+ trow .addToColumnValue (new TCell ().setStringVal ("" ));
747750 }
748751
749752 if (offsetProvider != null && StringUtils .isNotEmpty (offsetProvider .getShowMaxOffset ())) {
750753 trow .addToColumnValue (new TCell ().setStringVal (offsetProvider .getShowMaxOffset ()));
751754 } else {
752- trow .addToColumnValue (new TCell ().setStringVal (FeConstants . null_string ));
755+ trow .addToColumnValue (new TCell ().setStringVal ("" ));
753756 }
754757 if (tvfType != null ) {
755758 trow .addToColumnValue (new TCell ().setStringVal (
756- jobStatistic == null ? FeConstants . null_string : jobStatistic .toJson ()));
759+ jobStatistic == null ? "" : jobStatistic .toJson ()));
757760 } else {
758761 trow .addToColumnValue (new TCell ().setStringVal (
759- nonTxnJobStatistic == null ? FeConstants . null_string : nonTxnJobStatistic .toJson ()));
762+ nonTxnJobStatistic == null ? "" : nonTxnJobStatistic .toJson ()));
760763 }
761764 trow .addToColumnValue (new TCell ().setStringVal (failureReason == null
762- ? FeConstants . null_string : failureReason .getMsg ()));
765+ ? "" : failureReason .getMsg ()));
763766 trow .addToColumnValue (new TCell ().setStringVal (jobRuntimeMsg == null
764- ? FeConstants . null_string : jobRuntimeMsg ));
767+ ? "" : jobRuntimeMsg ));
765768 return trow ;
766769 }
767770
@@ -1064,7 +1067,7 @@ public void gsonPostProcess() throws IOException {
10641067 * The current streamingTask times out; create a new streamingTask.
10651068 * Only applies to StreamingMultiTask.
10661069 */
1067- public void processTimeoutTasks () {
1070+ public void processTimeoutTasks () throws JobException {
10681071 if (!(runningStreamTask instanceof StreamingMultiTblTask )) {
10691072 return ;
10701073 }
@@ -1073,16 +1076,8 @@ public void processTimeoutTasks() {
10731076 StreamingMultiTblTask runningMultiTask = (StreamingMultiTblTask ) this .runningStreamTask ;
10741077 if (TaskStatus .RUNNING .equals (runningMultiTask .getStatus ())
10751078 && runningMultiTask .isTimeout ()) {
1076- runningMultiTask .cancel (false );
1077- runningMultiTask .setErrMsg ("task cancelled cause timeout" );
1078-
1079- // renew streaming multi task
1080- this .runningStreamTask = createStreamingMultiTblTask ();
1081- Env .getCurrentEnv ().getJobManager ().getStreamingTaskManager ().registerTask (runningStreamTask );
1082- this .runningStreamTask .setStatus (TaskStatus .PENDING );
1083- log .info ("create new streaming multi tasks due to timeout, for job {}, task {} " ,
1084- getJobId (), runningStreamTask .getTaskId ());
1085- recordTasks (runningStreamTask );
1079+ runningMultiTask .onFail ("task failed cause timeout" );
1080+ // renew streaming task by auto resume
10861081 }
10871082 } finally {
10881083 writeUnlock ();
@@ -1096,20 +1091,22 @@ public void commitOffset(CommitOffsetRequest offsetRequest) throws JobException
10961091 }
10971092 writeLock ();
10981093 try {
1099- if (offsetRequest .getScannedRows () == 0 && offsetRequest .getScannedBytes () == 0 ) {
1100- JdbcSourceOffsetProvider op = (JdbcSourceOffsetProvider ) offsetProvider ;
1101- op .setHasMoreData (false );
1102- }
1103- updateNoTxnJobStatisticAndOffset (offsetRequest );
11041094 if (this .runningStreamTask != null
11051095 && this .runningStreamTask instanceof StreamingMultiTblTask ) {
11061096 if (this .runningStreamTask .getTaskId () != offsetRequest .getTaskId ()) {
11071097 throw new JobException ("Task id mismatch when commit offset. expected: "
11081098 + this .runningStreamTask .getTaskId () + ", actual: " + offsetRequest .getTaskId ());
11091099 }
1100+ updateNoTxnJobStatisticAndOffset (offsetRequest );
1101+ if (offsetRequest .getScannedRows () == 0 && offsetRequest .getScannedBytes () == 0 ) {
1102+ JdbcSourceOffsetProvider op = (JdbcSourceOffsetProvider ) offsetProvider ;
1103+ op .setHasMoreData (false );
1104+ }
1105+
11101106 persistOffsetProviderIfNeed ();
11111107 ((StreamingMultiTblTask ) this .runningStreamTask ).successCallback (offsetRequest );
11121108 }
1109+
11131110 } finally {
11141111 writeUnlock ();
11151112 }
@@ -1134,6 +1131,7 @@ public void replayOffsetProviderIfNeed() throws JobException {
11341131 * 2. Clean chunk info in meta table (jdbc)
11351132 */
11361133 public void cleanup () throws JobException {
1134+ log .info ("cleanup streaming job {}" , getJobId ());
11371135 // s3 tvf clean offset
11381136 if (tvfType != null && Config .isCloudMode ()) {
11391137 Cloud .DeleteStreamingJobResponse resp = null ;
0 commit comments