@@ -51,7 +51,7 @@ public class TemporalAttemptExecution<INPUT, OUTPUT> implements Supplier<OUTPUT>
51
51
private final Supplier <String > workflowIdProvider ;
52
52
private final AirbyteApiClient airbyteApiClient ;
53
53
private final String airbyteVersion ;
54
- private final Optional <String > workflowTaskQueue ;
54
+ private final Optional <String > replicationTaskQueue ;
55
55
56
56
public TemporalAttemptExecution (final Path workspaceRoot ,
57
57
final WorkerEnvironment workerEnvironment ,
@@ -86,7 +86,7 @@ public TemporalAttemptExecution(final Path workspaceRoot,
86
86
final AirbyteApiClient airbyteApiClient ,
87
87
final String airbyteVersion ,
88
88
final Supplier <ActivityExecutionContext > activityContext ,
89
- final Optional <String > workflowTaskQueue ) {
89
+ final Optional <String > replicationTaskQueue ) {
90
90
this (
91
91
workspaceRoot , workerEnvironment , logConfigs ,
92
92
jobRunConfig ,
@@ -97,7 +97,7 @@ public TemporalAttemptExecution(final Path workspaceRoot,
97
97
airbyteApiClient ,
98
98
() -> activityContext .get ().getInfo ().getWorkflowId (),
99
99
airbyteVersion ,
100
- workflowTaskQueue );
100
+ replicationTaskQueue );
101
101
}
102
102
103
103
@ VisibleForTesting
@@ -112,7 +112,7 @@ public TemporalAttemptExecution(final Path workspaceRoot,
112
112
final AirbyteApiClient airbyteApiClient ,
113
113
final Supplier <String > workflowIdProvider ,
114
114
final String airbyteVersion ,
115
- final Optional <String > workflowTaskQueue ) {
115
+ final Optional <String > replicationTaskQueue ) {
116
116
this .jobRunConfig = jobRunConfig ;
117
117
118
118
this .jobRoot = TemporalUtils .getJobRoot (workspaceRoot , jobRunConfig .getJobId (), jobRunConfig .getAttemptId ());
@@ -124,7 +124,7 @@ public TemporalAttemptExecution(final Path workspaceRoot,
124
124
125
125
this .airbyteApiClient = airbyteApiClient ;
126
126
this .airbyteVersion = airbyteVersion ;
127
- this .workflowTaskQueue = workflowTaskQueue ;
127
+ this .replicationTaskQueue = replicationTaskQueue ;
128
128
}
129
129
130
130
@ Override
@@ -139,8 +139,6 @@ public OUTPUT get() {
139
139
}
140
140
141
141
LOGGER .info ("Executing worker wrapper. Airbyte version: {}" , airbyteVersion );
142
- // TODO(Davin): This will eventually run into scaling problems, since it opens a DB connection per
143
- // workflow. See https://github.com/airbytehq/airbyte/issues/5936.
144
142
saveWorkflowIdForCancellation (airbyteApiClient );
145
143
146
144
final Worker <INPUT , OUTPUT > worker = workerSupplier .get ();
@@ -170,14 +168,18 @@ public OUTPUT get() {
170
168
private void saveWorkflowIdForCancellation (final AirbyteApiClient airbyteApiClient ) throws ApiException {
171
169
// If the jobId is not a number, it means the job is a synchronous job. No attempt is created for
172
170
// it, and it cannot be cancelled, so do not save the workflowId. See
173
- // SynchronousSchedulerClient.java
174
- // for info.
175
- if (NumberUtils .isCreatable (jobRunConfig .getJobId ())) {
171
+ // SynchronousSchedulerClient.java for info.
172
+ //
173
+ // At this moment(Nov 2022), we decide to save workflowId for cancellation purpose only at
174
+ // replication activity level. We know now the only async workflow is SyncWorkflow,
175
+ // and under the same workflow, the workflowId would stay the same,
176
+ // so it's not needed to save it for multiple times.
177
+ if (NumberUtils .isCreatable (jobRunConfig .getJobId ()) && replicationTaskQueue .isPresent ()) {
176
178
final String workflowId = workflowIdProvider .get ();
177
179
airbyteApiClient .getAttemptApi ().setWorkflowInAttempt (new SetWorkflowInAttemptRequestBody ()
178
180
.jobId (Long .parseLong (jobRunConfig .getJobId ()))
179
181
.attemptNumber (jobRunConfig .getAttemptId ().intValue ())
180
- .processingTaskQueue (workflowTaskQueue . orElse ( "" ))
182
+ .processingTaskQueue (replicationTaskQueue . get ( ))
181
183
.workflowId (workflowId ));
182
184
}
183
185
}
0 commit comments