Skip to content

Commit

Permalink
Merge pull request #158 from sylwiaszunejko/debug_scylla_bench
Browse files Browse the repository at this point in the history
Fix checking if tablets should be used in scyllaConnPicker Pick
  • Loading branch information
avelanarius authored Feb 7, 2024
2 parents 9dd9a7f + a39ad55 commit 3c32c6c
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions scylla.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,33 @@ func (p *scyllaConnPicker) Pick(t token, keyspace string, table string) *Conn {

idx := -1

p.conns[0].mu.Lock()
if p.conns[0].tabletsRoutingV1 {
tablets := p.conns[0].session.getTablets()

// Search for tablets with Keyspace and Table from the Query
l, r := findTablets(tablets, keyspace, table)

if l != -1 {
tablet := findTabletForToken(tablets, mmt, l, r)
for _, conn := range p.conns {
if conn == nil {
continue
}

for _, replica := range tablet.replicas {
if replica.hostId.String() == p.hostId {
idx = replica.shardId
conn.mu.Lock()
if conn.tabletsRoutingV1 {
tablets := conn.session.getTablets()

// Search for tablets with Keyspace and Table from the Query
l, r := findTablets(tablets, keyspace, table)

if l != -1 {
tablet := findTabletForToken(tablets, mmt, l, r)

for _, replica := range tablet.replicas {
if replica.hostId.String() == p.hostId {
idx = replica.shardId
}
}
}
}
conn.mu.Unlock()

break
}
p.conns[0].mu.Unlock()

if idx == -1 {
idx = p.shardOf(mmt)
}
Expand Down

0 comments on commit 3c32c6c

Please sign in to comment.