Skip to content

Commit

Permalink
Updates based on PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcfraser committed Oct 18, 2024
1 parent 5e8283d commit 6b87c41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions db/active_replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func connect(arc *activeReplicatorCommon, idSuffix string) (blipSender *blip.Sen
arc.replicationStats.NumConnectAttempts.Add(1)

var originPatterns []string // no origin headers for ISGR
// NewSGBlipContext doesn't set cancellation context - active replication cancellation on db close is handled independently
blipContext, err := NewSGBlipContext(arc.ctx, arc.config.ID+idSuffix, originPatterns, nil)
if err != nil {
return nil, nil, err
Expand Down
8 changes: 6 additions & 2 deletions db/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,13 @@ func NewDatabaseContext(ctx context.Context, dbName string, bucket base.Bucket,
UserFunctionTimeout: defaultUserFunctionTimeout,
}

// set up cancellable context based on the background context (context lifecycle should decoupled from the request context)
//
// set up cancellable context based on the background context (context lifecycle for the database
// must be distinct from the request context associated with the db create/update). Used to trigger
// teardown of connected replications on database close.
dbContext.CancelContext, dbContext.cancelContextFunc = context.WithCancel(context.Background())
cleanupFunctions = append(cleanupFunctions, func() {
dbContext.cancelContextFunc()
})

// Check if server version supports multi-xattr operations, required for mou handling
dbContext.EnableMou = bucket.IsSupported(sgbucket.BucketStoreFeatureMultiXattrSubdocOperations)
Expand Down
3 changes: 2 additions & 1 deletion rest/utilities_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,8 @@ func createBlipTesterWithSpec(tb testing.TB, spec BlipTesterSpec, rt *RestTester
if err != nil {
return nil, err
}
// Make BLIP/Websocket connection
// Make BLIP/Websocket connection. Not specifying cancellation context here as this is a
// client blip context that doesn't require cancellation-based close
bt.blipContext, err = db.NewSGBlipContextWithProtocols(base.TestCtx(tb), "", origin, protocols, nil)
if err != nil {
return nil, err
Expand Down

0 comments on commit 6b87c41

Please sign in to comment.