Skip to content
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

Support atomic writes in the docstore #3500

Merged
merged 3 commits into from
Jan 23, 2025

Conversation

sandeepvinayak
Copy link
Contributor

@sandeepvinayak sandeepvinayak commented Oct 11, 2024

docstore/all

Details in the issue : #3501

Please reference any Issue related to this Pull Request. Example: Fixes #1.

See
here
for tips on good Pull Request description.

Copy link

google-cla bot commented Oct 11, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@sandeepvinayak
Copy link
Contributor Author

@eliben @vangent We are trying to add the transactions support/atomic writes in the docstore and this is the high level idea of how can we support that in go-cloud. https://docs.google.com/document/d/1UVj1kmwDfrs5qm8r7X1p4fAFmsdPEeBHcvWJ8zWF1dY/edit?tab=t.0

The PR is just at a high level to support the idea.
Let me know what you think about it and we can help to drive it further.

@sandeepvinayak sandeepvinayak changed the title WIP: Support transaction in the docstore Support atomic writes in the docstore Dec 7, 2024
jba added a commit that referenced this pull request Dec 14, 2024
All modules are on a Go version after 1.18, so we can rename
interface{} to any to modernize the code.

docstore is omitted, because there are PRs in flight that this might
conflict with (#3500, #3508).
docstore/awsdynamodb/dynamo.go Show resolved Hide resolved
docstore/awsdynamodb/dynamo.go Show resolved Hide resolved
func (c *collection) transactWrite(ctx context.Context, actions []*driver.Action, errs []error, opts *driver.RunActionsOptions) {
if len(actions) == 0 {
return
}
setErr := func(err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is that if anything in this function fails, everything fails (since it's atomic). Document that here.

docstore/awsdynamodb/dynamo.go Outdated Show resolved Hide resolved
@@ -534,6 +537,12 @@ func (l *ActionList) String() string {
return "[" + strings.Join(as, ", ") + "]"
}

// AtomicWrites causes all following writes in the list to execute atomically.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to execute as a single atomic operation"

(to avoid confusion with the fact that each write already happens atomically by itself)

docstore/driver/util.go Outdated Show resolved Hide resolved
@@ -79,7 +79,7 @@ func TestGroupActions(t *testing.T) {
}{
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add various cases involving atomic writes, mixed with other writes and gets before, after, and concurrently.

docstore/drivertest/drivertest.go Outdated Show resolved Hide resolved
docstore/drivertest/drivertest.go Show resolved Hide resolved
docstore/memdocstore/mem.go Show resolved Hide resolved
@sandeepvinayak sandeepvinayak force-pushed the spal-transactions branch 2 times, most recently from d87f80e to aa357b9 Compare January 22, 2025 01:23
@sandeepvinayak
Copy link
Contributor Author

@jba thanks for your feedback, I addressed all of the comments, please take another look

docstore/awsdynamodb/dynamo.go Outdated Show resolved Hide resolved
docstore/drivertest/drivertest.go Outdated Show resolved Hide resolved
docstore/drivertest/drivertest.go Outdated Show resolved Hide resolved
@sandeepvinayak
Copy link
Contributor Author

@jba, I addressed your latest 2 comments

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 71.79487% with 11 lines in your changes missing coverage. Please review.

Project coverage is 73.28%. Comparing base (61f69d3) to head (8d0616d).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
docstore/awsdynamodb/dynamo.go 46.66% 8 Missing ⚠️
docstore/docstore.go 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3500      +/-   ##
==========================================
+ Coverage   73.26%   73.28%   +0.01%     
==========================================
  Files         113      113              
  Lines       15065    15080      +15     
==========================================
+ Hits        11038    11051      +13     
- Misses       3261     3263       +2     
  Partials      766      766              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sandeepvinayak
Copy link
Contributor Author

sandeepvinayak commented Jan 23, 2025

@jba the codecov report is under-reporting because the conformance tests are disabled for now but I verified the tests we added are good for dynamo. I will enable the 2 conformance tests added along with the other providers in the follow up PR.

@jba jba merged commit 4d1f585 into google:master Jan 23, 2025
6 checks passed
@jba
Copy link
Contributor

jba commented Jan 23, 2025

Thanks for the PR! Looking forward to the follow-ups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants