Skip to content

Commit

Permalink
CBG-4419 wait for xdcr to be finished
Browse files Browse the repository at this point in the history
  • Loading branch information
torcolvin committed Jan 10, 2025
1 parent 892bf3c commit c0b8352
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions xdcr/rosmar_xdcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (r replicatedDocLocation) String() string {
type rosmarManager struct {
filterFunc xdcrFilterFunc
terminator chan bool
doneChan chan struct{}
collectionsLock sync.RWMutex
fromBucketKeyspaces map[uint32]string
toBucketCollections map[uint32]*rosmar.Collection
Expand Down Expand Up @@ -223,6 +224,7 @@ func (r *rosmarManager) Start(ctx context.Context) error {
r.collectionsLock.Lock()
defer r.collectionsLock.Unlock()
r.terminator = make(chan bool)
r.doneChan = make(chan struct{})
// set up replication to target all existing collections, and map to other collections
scopes := make(map[string][]string)
fromDataStores, err := r.fromBucket.ListDataStores()
Expand Down Expand Up @@ -261,6 +263,7 @@ func (r *rosmarManager) Start(ctx context.Context) error {
args := sgbucket.FeedArguments{
ID: "xdcr-" + r.replicationID,
Terminator: r.terminator,
DoneChan: r.doneChan,
Scopes: scopes,
}

Expand All @@ -277,6 +280,8 @@ func (r *rosmarManager) Stop(_ context.Context) error {
return ErrReplicationNotRunning
}
close(r.terminator)
<-r.doneChan
r.doneChan = nil
r.terminator = nil
return nil
}
Expand Down

0 comments on commit c0b8352

Please sign in to comment.