Skip to content

Commit e0c2ed6

Browse files
DavidS-ovmactions-user
authored andcommitted
Improve wait-for-adapter behaviour (#1362)
GitOrigin-RevId: 214b92159975b52ac15b4a7e864a426727860bbe
1 parent b6a0ab7 commit e0c2ed6

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

aws-source/proc/proc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func InitializeAwsSourceEngine(ctx context.Context, ec *discovery.EngineConfig,
223223
var b backoff.BackOff
224224
b = backoff.NewExponentialBackOff(
225225
backoff.WithMaxInterval(30*time.Second),
226-
backoff.WithMaxElapsedTime(15*time.Minute),
226+
backoff.WithMaxElapsedTime(3*time.Minute), // do not wait longer than max allowed time for Change Analysis SLO
227227
)
228228
b = backoff.WithMaxRetries(b, maxRetries)
229229
tick := backoff.NewTicker(b)

discovery/enginerequests.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,17 @@ func (e *Engine) ExecuteQuery(ctx context.Context, query *sdp.Query, responses c
207207
p.Go(func() {
208208
defer tracing.LogRecoverToReturn(ctx, "ExecuteQuery inner")
209209
defer func() {
210+
// Mark the work as done. This happens before we start
211+
// waiting on `expandedMutex` below, to ensure that the
212+
// queues can continue executing even if we are waiting on
213+
// the mutex.
214+
wg.Done()
215+
210216
// Delete our query from the map so that we can track which
211217
// ones are still running
212218
expandedMutex.Lock()
213219
defer expandedMutex.Unlock()
214220
delete(expanded, localQ)
215-
216-
// Mark the work as done
217-
wg.Done()
218221
}()
219222
defer func() {
220223
if localQ.GetMethod() == sdp.QueryMethod_LIST {
@@ -252,8 +255,10 @@ func (e *Engine) ExecuteQuery(ctx context.Context, query *sdp.Query, responses c
252255
case <-ctx.Done():
253256
// The context was cancelled, this should have propagated to all the
254257
// adapters and therefore we should see the wait group finish very
255-
// quickly now. We will check this though to make sure
256-
longRunningAdaptersTimeout := 10 * time.Second
258+
// quickly now. We will check this though to make sure. This will wait
259+
// until we reach Change Analysis SLO violation territory. If this is
260+
// too quick, we are only spamming logs for nothing.
261+
longRunningAdaptersTimeout := 2 * time.Minute
257262

258263
// Wait for the wait group, but ping the logs if it's taking
259264
// too long

0 commit comments

Comments
 (0)