diff --git a/ais/metasync.go b/ais/metasync.go index 367d26cafa5..53e15587c32 100644 --- a/ais/metasync.go +++ b/ais/metasync.go @@ -94,6 +94,8 @@ const ( const failsync = "failing to sync" +const retryConnRefused = 4 + type ( revs interface { tag() string // enum { revsSmapTag, ... } @@ -218,7 +220,7 @@ func (y *metasyncer) Stop(err error) { func (y *metasyncer) notify(wait bool, pair revsPair) (failedCnt int) { var ( failedCntAtomic = atomic.NewInt32(0) - req = revsReq{pairs: []revsPair{pair}} + req = revsReq{pairs: []revsPair{pair}, reqType: reqNotify} ) if y.isPrimary() != nil { return @@ -227,7 +229,6 @@ func (y *metasyncer) notify(wait bool, pair revsPair) (failedCnt int) { req.wg = &sync.WaitGroup{} req.wg.Add(1) req.failedCnt = failedCntAtomic - req.reqType = reqNotify } y.workCh <- req @@ -369,7 +370,7 @@ func (y *metasyncer) do(pairs []revsPair, reqT int) (failedCnt int) { freeBcastRes(results) // step: handle connection-refused right away lr := len(refused) - for range 4 { // retry + for range retryConnRefused { if len(refused) == 0 { if lr > 0 { nlog.Infof("%s: %d node%s sync-ed", y.p, lr, cos.Plural(lr)) diff --git a/ais/prxclu.go b/ais/prxclu.go index 31f63610dd9..02610d032a8 100644 --- a/ais/prxclu.go +++ b/ais/prxclu.go @@ -729,7 +729,7 @@ func (p *proxy) mcastJoined(nsi *meta.Snode, msg *apc.ActMsg, flags cos.BitFlags interrupted: regReq.Flags.IsSet(cos.RebalanceInterrupted), restarted: regReq.Flags.IsSet(cos.Restarted), } - if err = p._earlyGFN(ctx, ctx.nsi); err != nil { + if err = p._earlyGFN(ctx, ctx.nsi, msg.Action, true /*joining*/); err != nil { return } if err = p.owner.smap.modify(ctx); err != nil { @@ -755,10 +755,10 @@ func (p *proxy) mcastJoined(nsi *meta.Snode, msg *apc.ActMsg, flags cos.BitFlags return } -func (p *proxy) _earlyGFN(ctx *smapModifier, si *meta.Snode /*being added or removed*/) error { +func (p *proxy) _earlyGFN(ctx *smapModifier, si *meta.Snode, action string, joining bool) error { smap := p.owner.smap.get() if !smap.isPrimary(p.si) { - return newErrNotPrimary(p.si, smap, fmt.Sprintf("cannot add %s", si)) + return newErrNotPrimary(p.si, smap, "cannot "+action+" "+si.StringEx()) } if si.IsProxy() { return nil @@ -770,6 +770,13 @@ func (p *proxy) _earlyGFN(ctx *smapModifier, si *meta.Snode /*being added or rem return err } + if smap.CountActiveTs() == 0 { + return nil + } + if !joining && smap.CountActiveTs() == 1 { + return nil + } + // early-GFN notification with an empty (version-only and not yet updated) Smap and // message(new target's ID) msg := p.newAmsgActVal(apc.ActStartGFN, nil) @@ -1539,7 +1546,7 @@ func (p *proxy) mcastMaint(msg *apc.ActMsg, si *meta.Snode, reb, maintPostReb bo msg: msg, skipReb: !reb, } - if err = p._earlyGFN(ctx, si); err != nil { + if err = p._earlyGFN(ctx, si, msg.Action, false /*joining*/); err != nil { return } if err = p.owner.smap.modify(ctx); err != nil {