Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transport: pool, stop shard refill faster when context is done #291

Open
Kulezi opened this issue Sep 16, 2022 · 0 comments · May be fixed by #295
Open

transport: pool, stop shard refill faster when context is done #291

Kulezi opened this issue Sep 16, 2022 · 0 comments · May be fixed by #295
Labels
bug Something isn't working transport

Comments

@Kulezi
Copy link
Contributor

Kulezi commented Sep 16, 2022

Checking if context is done should be checked in the loop, returning early without relying on the result of OpenShardConn.

func (r *PoolRefiller) fill(ctx context.Context) {
if !r.needsFilling() {
return
}
si := ShardInfo{
NrShards: uint16(r.pool.nrShards),
MsbIgnore: r.pool.msbIgnore,
}
for i := 0; i < r.pool.nrShards; i++ {
if r.pool.loadConn(i) != nil {
continue
}
si.Shard = uint16(i)
span := startSpan()
conn, err := OpenShardConn(ctx, r.addr, si, r.cfg)
span.stop()
if err != nil {
if r.pool.connObs != nil {
r.pool.connObs.OnConnect(ConnectEvent{ConnEvent: ConnEvent{Addr: r.addr, Shard: si.Shard}, span: span, Err: err})
}
if conn != nil {
conn.Close()
}
continue
}
if r.pool.connObs != nil {
r.pool.connObs.OnConnect(ConnectEvent{ConnEvent: conn.Event(), span: span})
}
if conn.Shard() != i {
log.Fatalf("opened conn to wrong shard: expected %d got %d", i, conn.Shard())
}
conn.setOnClose(r.onConnClose)
r.pool.storeConn(conn)
r.active++
if !r.needsFilling() {
return
}
}
}

@Kulezi Kulezi added bug Something isn't working transport labels Sep 16, 2022
@Kulezi Kulezi linked a pull request Sep 23, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working transport
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant