This repository was archived by the owner on Jul 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
This repository was archived by the owner on Jul 21, 2025. It is now read-only.
transport: pool, stop shard refill faster when context is done #291
Copy link
Copy link
Open
Labels
Description
Checking if context is done should be checked in the loop, returning early without relying on the result of OpenShardConn.
scylla-go-driver/transport/pool.go
Lines 221 to 264 in 88fc8ef
| 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 | |
| } | |
| } | |
| } |