Skip to content

Commit

Permalink
metasync: amend GFN notifications
Browse files Browse the repository at this point in the history
* always notify via metasync-post
* add extra checks when _not_ to

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Jul 23, 2024
1 parent 162dfef commit 1a01903
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 4 additions & 3 deletions ais/metasync.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ const (

const failsync = "failing to sync"

const retryConnRefused = 4

type (
revs interface {
tag() string // enum { revsSmapTag, ... }
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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))
Expand Down
15 changes: 11 additions & 4 deletions ais/prxclu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1a01903

Please sign in to comment.