Skip to content

Commit 2ab4c28

Browse files
committed
get-batch: handle stream breakages (ErrSBR); per-request polling and cleanup
* propagate ErrSBR from shared-DM recv() to x-moss * add transport.ErrSBR timestamps and helpers - Since(), IsErrSBR(), AsErrSBR() * maintain versioned ErrSBR map (r.sbrs) with per-WI (per get-batch) cache * add checkSBR() to detect recent SBRs for the current sender * extend waitFlushRx() loop to poll periodically and abort affected WIDs * reuse timers in waitAnyRx to reduce allocations - work item cleanup: stop and drain * simplify wakeup semantics; assembler thread polls and reacts on its own * add bounded ErrSBR window (hardcoded 4s) and polling interval (1/10th timeout) * minor log and comment updates (see "ref 032011" marker) Signed-off-by: Alex Aizman <alex.aizman@gmail.com>
1 parent d0c7d7e commit 2ab4c28

5 files changed

Lines changed: 188 additions & 62 deletions

File tree

ais/ml.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,11 @@ func (ctx *mossCtx) phase2(w http.ResponseWriter, r *http.Request, smap *smapX,
390390
return
391391
}
392392
if err := xmoss.Send(ctx.req, &smap.Smap, tsi, ctx.wid, usingPrev); err != nil {
393-
// NOTE: not aborting x-moss on a single wid failure
393+
//
394+
// not aborting x-moss on a single wid failure; silent log
395+
//
394396
xmoss.AddErr(fmt.Errorf("send wid=%s: %v", ctx.wid, err), 4, cos.ModXs)
395-
t.writeErr(w, r, err)
397+
t.writeErr(w, r, err, 0, Silent)
396398
}
397399
}
398400

transport/bundle/shared_dm.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (sdm *sharedDM) Open() error {
115115
return nil
116116
}
117117

118+
// TODO: prevent a) too-frequent reconnects and/or b) too-many-during-stream's-lifetime :TODO
118119
func (sdm *sharedDM) reconnect(dstID string, err error) {
119120
if !sdm.isOpen() {
120121
return
@@ -209,6 +210,26 @@ func (sdm *sharedDM) Bcast(obj *transport.Obj, roc cos.ReadOpenCloser) error {
209210

210211
func (sdm *sharedDM) recv(hdr *transport.ObjHdr, r io.Reader, err error) error {
211212
if err != nil {
213+
//
214+
// `transport.ErrSBR` => all reg-ed receivers
215+
//
216+
if e := transport.AsErrSBR(err); e != nil {
217+
// clone to call outside rlock
218+
sdm.rxmu.RLock()
219+
receivers := make([]transport.Receiver, 0, len(sdm.receivers))
220+
for xid := range sdm.receivers {
221+
receivers = append(receivers, sdm.receivers[xid].rx)
222+
}
223+
sdm.rxmu.RUnlock()
224+
225+
for _, rx := range receivers {
226+
_ = rx.RecvObj(hdr, nil, e)
227+
}
228+
229+
clear(receivers)
230+
return nil
231+
}
232+
212233
return err
213234
}
214235
xid := hdr.Demux

transport/err.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ package transport
66

77
import (
88
"strings"
9+
"time"
910

1011
"github.com/NVIDIA/aistore/cmn/debug"
12+
"github.com/NVIDIA/aistore/cmn/mono"
1113
)
1214

1315
// ErrSBR codes (receive-side stream breakage)
@@ -43,6 +45,7 @@ type (
4345
sid string // sender node ID
4446
code string
4547
ctx string
48+
ts int64
4649
}
4750
)
4851

@@ -100,8 +103,14 @@ func (e *ErrSBR) Error() string {
100103
return sb.String()
101104
}
102105

103-
func (e *ErrSBR) Unwrap() error { return e.err }
104-
func (e *ErrSBR) SID() string { return e.sid }
106+
func (e *ErrSBR) Unwrap() error { return e.err }
107+
func (e *ErrSBR) SID() string { return e.sid }
108+
func (e *ErrSBR) Since() time.Duration { return mono.Since(e.ts) }
109+
110+
func IsErrSBR(err error) bool {
111+
_, ok := err.(*ErrSBR)
112+
return ok
113+
}
105114

106115
func AsErrSBR(err error) *ErrSBR {
107116
if e, ok := err.(*ErrSBR); ok {

transport/recv.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/NVIDIA/aistore/cmn/atomic"
1919
"github.com/NVIDIA/aistore/cmn/cos"
2020
"github.com/NVIDIA/aistore/cmn/debug"
21+
"github.com/NVIDIA/aistore/cmn/mono"
2122
"github.com/NVIDIA/aistore/cmn/nlog"
2223
"github.com/NVIDIA/aistore/core"
2324
"github.com/NVIDIA/aistore/memsys"
@@ -299,6 +300,7 @@ func (it *iterator) newErr(err error, code, ctx string) error {
299300
sid: it.sid,
300301
code: code,
301302
ctx: ctx,
303+
ts: mono.NanoTime(),
302304
}
303305
}
304306

0 commit comments

Comments
 (0)