Skip to content

Commit

Permalink
fix(spanner): fix integration tests data race (#7229)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Jan 10, 2023
1 parent 88adaa2 commit a741024
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spanner/internal/testutil/inmem_spanner_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,8 @@ func (s *inMemSpannerServer) ExecuteSql(ctx context.Context, req *spannerpb.Exec
if err != nil {
return nil, err
}
statementResult = statementResult.getResultSetWithTransactionSet(req.GetTransaction(), id)
s.mu.Lock()
statementResult = statementResult.getResultSetWithTransactionSet(req.GetTransaction(), id)
isPartitionedDml := s.partitionedDmlTransactions[string(id)]
s.mu.Unlock()
switch statementResult.Type {
Expand Down Expand Up @@ -874,8 +874,8 @@ func (s *inMemSpannerServer) executeStreamingSQL(req *spannerpb.ExecuteSqlReques
if err != nil {
return err
}
statementResult.getResultSetWithTransactionSet(req.GetTransaction(), id)
s.mu.Lock()
statementResult.getResultSetWithTransactionSet(req.GetTransaction(), id)
isPartitionedDml := s.partitionedDmlTransactions[string(id)]
s.mu.Unlock()
switch statementResult.Type {
Expand Down Expand Up @@ -948,7 +948,9 @@ func (s *inMemSpannerServer) ExecuteBatchDml(ctx context.Context, req *spannerpb
if err != nil {
return nil, err
}
s.mu.Lock()
statementResult = statementResult.getResultSetWithTransactionSet(req.GetTransaction(), id)
s.mu.Unlock()
switch statementResult.Type {
case StatementResultError:
resp.Status = &status.Status{Code: int32(gstatus.Code(statementResult.Err)), Message: statementResult.Err.Error()}
Expand Down

0 comments on commit a741024

Please sign in to comment.