@@ -578,11 +578,17 @@ func (s *ContextImpl) UpdateNamespaceNotificationVersion(namespaceNotificationVe
578
578
return nil
579
579
}
580
580
581
- func (s * ContextImpl ) UpdateHandoverNamespaces (ns * namespace.Namespace , deletedFromDb bool ) {
581
+ func (s * ContextImpl ) UpdateHandoverNamespace (ns * namespace.Namespace , deletedFromDb bool ) {
582
582
nsName := ns .Name ()
583
+ // NOTE: replication state field won't be replicated and currently we only update a namespace
584
+ // to handover state from active cluster, so the second condition will always be true. Adding
585
+ // it here to be more safe in case above assumption no longer holds in the future.
586
+ isHandoverNamespace := ns .IsGlobalNamespace () &&
587
+ ns .ActiveInCluster (s .GetClusterMetadata ().GetCurrentClusterName ()) &&
588
+ ns .ReplicationState () == enums .REPLICATION_STATE_HANDOVER
583
589
584
590
s .wLock ()
585
- if deletedFromDb {
591
+ if deletedFromDb || ! isHandoverNamespace {
586
592
delete (s .handoverNamespaces , ns .Name ())
587
593
s .wUnlock ()
588
594
return
@@ -595,23 +601,15 @@ func (s *ContextImpl) UpdateHandoverNamespaces(ns *namespace.Namespace, deletedF
595
601
maxReplicationTaskID = pendingMaxReplicationTaskID
596
602
}
597
603
598
- // NOTE: replication state field won't be replicated and currently we only update a namespace
599
- // to handover state from active cluster, so the second condition will always be true. Adding
600
- // it here to be more safe in case above assumption no longer holds in the future.
601
- if ns .IsGlobalNamespace () &&
602
- ns .ActiveInCluster (s .GetClusterMetadata ().GetCurrentClusterName ()) &&
603
- ns .ReplicationState () == enums .REPLICATION_STATE_HANDOVER {
604
-
605
- if handover , ok := s .handoverNamespaces [nsName ]; ok {
606
- if handover .NotificationVersion < ns .NotificationVersion () {
607
- handover .NotificationVersion = ns .NotificationVersion ()
608
- handover .MaxReplicationTaskID = maxReplicationTaskID
609
- }
610
- } else {
611
- s .handoverNamespaces [nsName ] = & namespaceHandOverInfo {
612
- NotificationVersion : ns .NotificationVersion (),
613
- MaxReplicationTaskID : maxReplicationTaskID ,
614
- }
604
+ if handover , ok := s .handoverNamespaces [nsName ]; ok {
605
+ if handover .NotificationVersion < ns .NotificationVersion () {
606
+ handover .NotificationVersion = ns .NotificationVersion ()
607
+ handover .MaxReplicationTaskID = maxReplicationTaskID
608
+ }
609
+ } else {
610
+ s .handoverNamespaces [nsName ] = & namespaceHandOverInfo {
611
+ NotificationVersion : ns .NotificationVersion (),
612
+ MaxReplicationTaskID : maxReplicationTaskID ,
615
613
}
616
614
}
617
615
0 commit comments