You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, in watchGrpcStream's run() method, only ONE creation request is send to etcd server at any given time
for {
select {
casereq:=<-w.reqc:
switchwreq:=req.(type) {
case*watchRequest:
// queue up for watcher creation/resumew.resuming=append(w.resuming, ws)
iflen(w.resuming) ==1 { // only send out if it's the only request?// head of resume queue, can register a new watcheriferr:=wc.Send(ws.initReq.toPB()); err!=nil {
w.lg.Debug("error when sending request", zap.Error(err))
}
}
case pbresp :=<-w.respc:
switch {
casepbresp.Created:
// response to head of queue creationiflen(w.resuming) !=0 {
ifws:=w.resuming[0]; ws!=nil {
w.addSubstream(pbresp, ws)
w.dispatchEvent(pbresp)
w.resuming[0] =nil
}
}
}
}
}
Therefore, there are chances that:
I call watcher.Watch() for key A, key B, key C from different goroutines, (without timeout contexts)
And etcd server is failed to response creation result immediately (because of network latency maybe)
Then only the first watch request is sent to etcd server, others will be omitted
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When my service starts, I instantiate one v3 client
Later in my service, I regularly watch for keys, in different places
Is it safe to do that?
From my observation, in
watch.go
the watcher will reuse the samewatchGrpcStream
instance, since the contexts are the same.However, in
watchGrpcStream
'srun()
method, only ONE creation request is send to etcd server at any given timeTherefore, there are chances that:
watcher.Watch()
for key A, key B, key C from different goroutines, (without timeout contexts)watch
request is sent to etcd server, others will be omittedBeta Was this translation helpful? Give feedback.
All reactions