Skip to content

Commit 3c32c6c

Browse files
authored
Merge pull request scylladb#158 from sylwiaszunejko/debug_scylla_bench
Fix checking if tablets should be used in scyllaConnPicker Pick
2 parents 9dd9a7f + a39ad55 commit 3c32c6c

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

scylla.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -370,24 +370,33 @@ func (p *scyllaConnPicker) Pick(t token, keyspace string, table string) *Conn {
370370

371371
idx := -1
372372

373-
p.conns[0].mu.Lock()
374-
if p.conns[0].tabletsRoutingV1 {
375-
tablets := p.conns[0].session.getTablets()
376-
377-
// Search for tablets with Keyspace and Table from the Query
378-
l, r := findTablets(tablets, keyspace, table)
379-
380-
if l != -1 {
381-
tablet := findTabletForToken(tablets, mmt, l, r)
373+
for _, conn := range p.conns {
374+
if conn == nil {
375+
continue
376+
}
382377

383-
for _, replica := range tablet.replicas {
384-
if replica.hostId.String() == p.hostId {
385-
idx = replica.shardId
378+
conn.mu.Lock()
379+
if conn.tabletsRoutingV1 {
380+
tablets := conn.session.getTablets()
381+
382+
// Search for tablets with Keyspace and Table from the Query
383+
l, r := findTablets(tablets, keyspace, table)
384+
385+
if l != -1 {
386+
tablet := findTabletForToken(tablets, mmt, l, r)
387+
388+
for _, replica := range tablet.replicas {
389+
if replica.hostId.String() == p.hostId {
390+
idx = replica.shardId
391+
}
386392
}
387393
}
388394
}
395+
conn.mu.Unlock()
396+
397+
break
389398
}
390-
p.conns[0].mu.Unlock()
399+
391400
if idx == -1 {
392401
idx = p.shardOf(mmt)
393402
}

0 commit comments

Comments
 (0)