Skip to content

Commit

Permalink
fakesqldb: Guard query log usage with lock (vitessio#12813)
Browse files Browse the repository at this point in the history
* fakesqldb: Guard query log usage with lock

This lock is used around adding to the query log, but it means we also
need to use the lock when reading from it or when resetting it.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* grpcvtctldserver: Fix alias for loop reuse

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* unit_race: Increase runtime

We've been adding a lot of tests for the evalengine and we're bumping up
to the timeout.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

---------

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
  • Loading branch information
dbussink authored and timvaillancourt committed Aug 20, 2024
1 parent d15c1b4 commit 4344212
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_race.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true'
uses: nick-fields/retry@v2
with:
timeout_minutes: 30
timeout_minutes: 45
max_attempts: 3
retry_on: error
command: |
Expand Down
4 changes: 4 additions & 0 deletions go/mysql/fakesqldb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,15 @@ func (db *DB) GetQueryCalledNum(query string) int {

// QueryLog returns the query log in a semicomma separated string
func (db *DB) QueryLog() string {
db.mu.Lock()
defer db.mu.Unlock()
return strings.Join(db.querylog, ";")
}

// ResetQueryLog resets the query log
func (db *DB) ResetQueryLog() {
db.mu.Lock()
defer db.mu.Unlock()
db.querylog = nil
}

Expand Down
4 changes: 3 additions & 1 deletion go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4168,7 +4168,9 @@ func (s *VtctldServer) ValidateVersionShard(ctx context.Context, req *vtctldatap
}

wg.Add(1)
go s.diffVersion(ctx, primaryVersion.Version, shard.PrimaryAlias, alias, &wg, &er)
go func(alias *topodatapb.TabletAlias) {
s.diffVersion(ctx, primaryVersion.Version, shard.PrimaryAlias, alias, &wg, &er)
}(alias)
}

wg.Wait()
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtctl/grpcvtctldserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2705,7 +2705,7 @@ func TestDeleteShards(t *testing.T) {
defer func() {
topofactory.SetError(nil)

actualShards := []*vtctldatapb.Shard{}
var actualShards []*vtctldatapb.Shard

keyspaces, err := ts.GetKeyspaces(ctx)
require.NoError(t, err, "cannot get keyspace names to check remaining shards")
Expand Down

0 comments on commit 4344212

Please sign in to comment.