TBR Syncbase discovery: Preserve adIds across advertisements.
This is important to prevent trampling in the discovery state maintained
by syncbase's scan.
MultiPart: 2/2
Change-Id: I89356a6b717623cf6e67f440fa5bf726bb6ca98e
diff --git a/services/syncbase/vsync/sync.go b/services/syncbase/vsync/sync.go
index 8640fe6..cf23497 100644
--- a/services/syncbase/vsync/sync.go
+++ b/services/syncbase/vsync/sync.go
@@ -139,6 +139,7 @@
type syncAdvertisementState struct {
cancel context.CancelFunc // cancels advertising.
specVersion string // version of most recently advertised spec.
+ adId discovery.AdId
}
var (
@@ -518,7 +519,8 @@
return err
}
- if state, advertising := s.advSyncgroups[gid]; advertising {
+ state, advertising := s.advSyncgroups[gid]
+ if advertising {
// The spec hasn't changed since the last advertisement.
if sg.SpecVersion == state.specVersion {
return nil
@@ -542,6 +544,9 @@
wire.DiscoveryAttrSyncgroupBlessing: sg.Id.Blessing,
},
}
+ if advertising {
+ sbService.Id = state.adId
+ }
ctx, stop := context.WithCancel(s.ctx)
vlog.VI(4).Infof("sync: advertiseSyncgroupInNeighborhood: advertising %v", sbService)
@@ -554,7 +559,7 @@
_, err = idiscovery.AdvertiseServer(ctx, s.discovery, s.svr, "", &sbService, visibility)
if err == nil {
vlog.VI(4).Infof("sync: advertiseSyncgroupInNeighborhood: successful")
- s.advSyncgroups[gid] = syncAdvertisementState{cancel: stop, specVersion: sg.SpecVersion}
+ s.advSyncgroups[gid] = syncAdvertisementState{cancel: stop, specVersion: sg.SpecVersion, adId: sbService.Id}
return nil
}
stop()
diff --git a/services/syncbase/vsync/syncgroup.go b/services/syncbase/vsync/syncgroup.go
index 763807d..6db580d 100644
--- a/services/syncbase/vsync/syncgroup.go
+++ b/services/syncbase/vsync/syncgroup.go
@@ -1277,7 +1277,7 @@
// Try to join using an Admin on neighborhood in case this node does not
// have connectivity.
neighbors := ss.filterSyncgroupAdmins(dbId, sgId)
- c = interfaces.SyncClient("")
+ c := interfaces.SyncClient("")
for _, svc := range neighbors {
me := &naming.MountEntry{IsLeaf: true, Name: common.SyncbaseSuffix}
// TODO(fredq): check that the service at addr has the expectedSyncbaseBlessings.