-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(spanner): inline begin transaction for ReadWriteTransactions #7149
Merged
Merged
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
a7410ac
feat(spanner): inline begin transaction
rahul2393 493e538
Merge branch 'main' into inline-begin-transaction
rahul2393 44af2f6
fix apidiff install issue
rahul2393 c94939b
fix github workflow install issue
rahul2393 aa5d55a
add test to for a read/write transaction executing two queries in par…
rahul2393 03f03c2
incorporate requested changes
rahul2393 1405187
fix check
rahul2393 0d8e9c7
Merge branch 'main' into inline-begin-transaction
rahul2393 883021f
incorporate requested changes
rahul2393 8796c70
Merge branch 'main' into inline-begin-transaction
rahul2393 ba363c8
minor fixes
rahul2393 7d357c4
fix benchmark tests
rahul2393 88d075b
Merge branch 'main' into inline-begin-transaction
rahul2393 136af30
feat(spanner): testcase fixes
harshachinta 7c17277
feat(spanner): nit add key to struct
harshachinta 50281ee
incoporate suggested changes
rahul2393 b304bb0
Merge branch 'main' into inline-begin-transaction
rahul2393 17f7b10
Merge branch 'main' into inline-begin-transaction
rahul2393 464bce1
incorporate requested changes
rahul2393 b9b184e
Merge branch 'main' into inline-begin-transaction
rahul2393 20a6da8
Merge branch 'main' into inline-begin-transaction
rahul2393 f15c6ad
re-trigger checks
rahul2393 5a44cd5
Merge branch 'main' into inline-begin-transaction
rahul2393 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,22 +174,26 @@ func (s *StatementResult) updateCountToPartialResultSet(exact bool) *spannerpb.P | |
// Converts an update count to a ResultSet, as DML statements also return the | ||
// update count as the statistics of a ResultSet. | ||
func (s *StatementResult) convertUpdateCountToResultSet(exact bool) *spannerpb.ResultSet { | ||
rs := &spannerpb.ResultSet{ | ||
Stats: &spannerpb.ResultSetStats{ | ||
RowCount: &spannerpb.ResultSetStats_RowCountLowerBound{ | ||
RowCountLowerBound: s.UpdateCount, | ||
}, | ||
}, | ||
} | ||
if exact { | ||
return &spannerpb.ResultSet{ | ||
rs = &spannerpb.ResultSet{ | ||
Stats: &spannerpb.ResultSetStats{ | ||
RowCount: &spannerpb.ResultSetStats_RowCountExact{ | ||
RowCountExact: s.UpdateCount, | ||
}, | ||
}, | ||
} | ||
} | ||
return &spannerpb.ResultSet{ | ||
Stats: &spannerpb.ResultSetStats{ | ||
RowCount: &spannerpb.ResultSetStats_RowCountLowerBound{ | ||
RowCountLowerBound: s.UpdateCount, | ||
}, | ||
}, | ||
if s.ResultSet != nil { | ||
rs.Metadata = s.ResultSet.Metadata | ||
} | ||
return rs | ||
} | ||
|
||
// SimulatedExecutionTime represents the time the execution of a method | ||
|
@@ -787,6 +791,15 @@ func (s *inMemSpannerServer) ExecuteSql(ctx context.Context, req *spannerpb.Exec | |
if err != nil { | ||
return nil, err | ||
} | ||
if _, ok := req.GetTransaction().GetSelector().(*spannerpb.TransactionSelector_Begin); ok { | ||
rahul2393 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if statementResult.ResultSet == nil { | ||
statementResult.ResultSet = &spannerpb.ResultSet{} | ||
} | ||
if statementResult.ResultSet.Metadata == nil { | ||
statementResult.ResultSet.Metadata = &spannerpb.ResultSetMetadata{} | ||
} | ||
statementResult.ResultSet.Metadata.Transaction = &spannerpb.Transaction{Id: id} | ||
} | ||
s.mu.Lock() | ||
isPartitionedDml := s.partitionedDmlTransactions[string(id)] | ||
s.mu.Unlock() | ||
|
@@ -833,6 +846,15 @@ func (s *inMemSpannerServer) executeStreamingSQL(req *spannerpb.ExecuteSqlReques | |
if err != nil { | ||
return err | ||
} | ||
if _, ok := req.GetTransaction().GetSelector().(*spannerpb.TransactionSelector_Begin); ok { | ||
if statementResult.ResultSet == nil { | ||
statementResult.ResultSet = &spannerpb.ResultSet{} | ||
} | ||
if statementResult.ResultSet.Metadata == nil { | ||
statementResult.ResultSet.Metadata = &spannerpb.ResultSetMetadata{} | ||
} | ||
statementResult.ResultSet.Metadata.Transaction = &spannerpb.Transaction{Id: id} | ||
} | ||
s.mu.Lock() | ||
isPartitionedDml := s.partitionedDmlTransactions[string(id)] | ||
s.mu.Unlock() | ||
|
@@ -906,6 +928,15 @@ func (s *inMemSpannerServer) ExecuteBatchDml(ctx context.Context, req *spannerpb | |
if err != nil { | ||
return nil, err | ||
} | ||
if _, ok := req.GetTransaction().GetSelector().(*spannerpb.TransactionSelector_Begin); ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this also use the helper method |
||
if statementResult.ResultSet == nil { | ||
statementResult.ResultSet = &spannerpb.ResultSet{} | ||
} | ||
if statementResult.ResultSet.Metadata == nil { | ||
statementResult.ResultSet.Metadata = &spannerpb.ResultSetMetadata{} | ||
} | ||
statementResult.ResultSet.Metadata.Transaction = &spannerpb.Transaction{Id: id} | ||
} | ||
switch statementResult.Type { | ||
case StatementResultError: | ||
resp.Status = &status.Status{Code: int32(gstatus.Code(statementResult.Err)), Message: statementResult.Err.Error()} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: below in this test a goroutine is launched with the arg b. Calling fatal in a launched goroutine from a test can cause the whole suite to fail. Should be converted to an error or errors collected and considered fatal back in the main goroutine. I see this in several tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @codyoss for suggestion, will be doing benchmark changes in another PR, since we are not changing benchmark tests itself as part of this feature wanted to have improvements separate.