Changes for todos app.
1) Ensure that JoinSyncgroup doesn't attempt the cloud peer, if
we don't have a remoteSyncbaseName. Otherwise we'll try to send
the JoinSyncgroupAtAdmin rpc and must wait for the timeout,
wasting 2 seconds.
2) Reduce the MDNS refresh period to 5 seconds. This makes
things snappier, and also seems to avoid some of the bad cases
where we don't process advertisements at all.
Change-Id: I32dbe6d23e2796677f17868c88c99a6220f58028
diff --git a/lib/discovery/plugins/mdns/mdns.go b/lib/discovery/plugins/mdns/mdns.go
index 4fb4faf..77dae7e 100644
--- a/lib/discovery/plugins/mdns/mdns.go
+++ b/lib/discovery/plugins/mdns/mdns.go
@@ -453,7 +453,7 @@
mdns: m,
adStopper: idiscovery.NewTrigger(),
// TODO(jhahn): Figure out a good subscription refresh time.
- subscriptionRefreshTime: 15 * time.Second,
+ subscriptionRefreshTime: 5 * time.Second,
subscription: make(map[string]subscription),
}
if loopback {
diff --git a/services/syncbase/vsync/syncgroup.go b/services/syncbase/vsync/syncgroup.go
index 847bf40..593d2b0 100644
--- a/services/syncbase/vsync/syncgroup.go
+++ b/services/syncbase/vsync/syncgroup.go
@@ -1254,17 +1254,18 @@
func (sd *syncDatabase) joinSyncgroupAtAdmin(ctxIn *context.T, call rpc.ServerCall, dbId, sgId wire.Id, remoteSyncbaseName string, expectedSyncbaseBlessings []string, localSyncbaseName string, myInfo wire.SyncgroupMemberInfo) (interfaces.Syncgroup, string, interfaces.GenVector, error) {
vlog.VI(2).Infof("sync: joinSyncgroupAtAdmin: begin, dbId %v, sgId %v, remoteSyncbaseName %v", dbId, sgId, remoteSyncbaseName)
- ctx, cancel := context.WithTimeout(ctxIn, cloudConnectionTimeout)
- c := interfaces.SyncClient(naming.Join(remoteSyncbaseName, common.SyncbaseSuffix))
- sg, vers, gv, err := c.JoinSyncgroupAtAdmin(ctx, dbId, sgId, localSyncbaseName, myInfo)
- cancel()
-
- if err == nil {
- vlog.VI(2).Infof("sync: joinSyncgroupAtAdmin: end succeeded at %v, returned sg %v vers %v gv %v", sgId, sg, vers, gv)
- return sg, vers, gv, err
+ if remoteSyncbaseName != "" {
+ ctx, cancel := context.WithTimeout(ctxIn, cloudConnectionTimeout)
+ c := interfaces.SyncClient(naming.Join(remoteSyncbaseName, common.SyncbaseSuffix))
+ sg, vers, gv, err := c.JoinSyncgroupAtAdmin(ctx, dbId, sgId, localSyncbaseName, myInfo)
+ cancel()
+ if err == nil {
+ vlog.VI(2).Infof("sync: joinSyncgroupAtAdmin: end succeeded at %v, returned sg %v vers %v gv %v", sgId, sg, vers, gv)
+ return sg, vers, gv, err
+ }
}
- vlog.VI(2).Infof("sync: joinSyncgroupAtAdmin: try neighborhood %v since the join failed, %v", sgId, err)
+ vlog.VI(2).Infof("sync: joinSyncgroupAtAdmin: try neighborhood %v", sgId)
// TODO(hpucha): Restrict the set of errors when retry happens to
// network related errors or other retriable errors.
@@ -1291,7 +1292,7 @@
}
vlog.VI(2).Infof("sync: joinSyncgroupAtAdmin: failed %v", sgId)
- return interfaces.Syncgroup{}, "", interfaces.GenVector{}, verror.New(wire.ErrSyncgroupJoinFailed, ctx)
+ return interfaces.Syncgroup{}, "", interfaces.GenVector{}, verror.New(wire.ErrSyncgroupJoinFailed, ctxIn)
}
func authorize(ctx *context.T, call security.Call, sg *interfaces.Syncgroup) error {