-
Notifications
You must be signed in to change notification settings - Fork 37
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
Disable implicit pre-read by default for Put operations #1336
Disable implicit pre-read by default for Put operations #1336
Conversation
docs/api-guide.md
Outdated
{% capture notice--info %} | ||
**Note** | ||
|
||
When you update an existing record, you need to read the record by using `Get` or `Scan` before using a `Put` operation. Otherwise, the operation will fail due to a conflict. This occurs because ScalarDB assumes that another transaction wrote the record. Instead of reading the record explicitly, you can enable implicit pre-read. See [Enable implicit pre-read for `Put` operations](#enable-implicit-pre-read-for-put-operations) for details. |
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.
Otherwise, the operation will fail due to a conflict. This occurs because ScalarDB assumes that another transaction wrote the record
My understanding is as follows
- ScalarDB needs to detect if another transaction wrote the record (== conflict)
Put
operation without reading the record will fail since ScalarDB can't check the conflict
If it's correct, there might be room to make the description clearer.
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.
I think your understanding is correct. However, since this document is not intended to explain the details of the transaction mechanism in ScalarDB, we might not need to explain it deeply here. Or do you have an idea for this? If yes, can you please suggest it? Thanks.
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.
It might be a bit deep (so it might not be proper for this document), but how about the following description?
When you update an existing record, you need to read the record by using `Get` or `Scan` before using a `Put` operation. Otherwise, the operation will fail due to a conflict. This occurs because ScalarDB assumes that another transaction wrote the record. Instead of reading the record explicitly, you can enable implicit pre-read. See [Enable implicit pre-read for `Put` operations](#enable-implicit-pre-read-for-put-operations) for details. | |
When you update an existing record, you need to read the record by using `Get` or `Scan` before using a `Put` operation. Otherwise, the operation will fail due to a conflict. ScalarDB needs to check whether another transaction wrote the record for concurrency control when it runs write operations, but ScalarDB cannot do that if you don't read the existing record before write operations. This causes the conflict error. Instead of reading the record explicitly, you can enable implicit pre-read. See [Enable implicit pre-read for `Put` operations](#enable-implicit-pre-read-for-put-operations) for details. |
Or, how about the following simple description? I think this is not a deep.
When you update an existing record, you need to read the record by using `Get` or `Scan` before using a `Put` operation. Otherwise, the operation will fail due to a conflict. This occurs because ScalarDB assumes that another transaction wrote the record. Instead of reading the record explicitly, you can enable implicit pre-read. See [Enable implicit pre-read for `Put` operations](#enable-implicit-pre-read-for-put-operations) for details. | |
When you update an existing record, you need to read the record by using `Get` or `Scan` before using a `Put` operation. Otherwise, the operation will fail due to a conflict. This occurs because the specification of ScalarDB to manage transactions properly. Instead of reading the record explicitly, you can enable implicit pre-read. See [Enable implicit pre-read for `Put` operations](#enable-implicit-pre-read-for-put-operations) for details. |
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.
@komamitsu (CC: @feeblefakie) What do you think about @kota2and3kan's idea?
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.
I noticed Enable implicit pre-read for Put
operations already has a detailed description about the background. So, the following simple one is okay?
When you update an existing record, you need to read the record by using `Get` or `Scan` before using a `Put` operation. The implicit pre-read feature would be useful for that. See [Enable implicit pre-read for `Put` operations](#enable-implicit-pre-read-for-put-operations) for details.
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.
When you update an existing record, you need to read the record by using
Get
orScan
before using aPut
operation. Otherwise, the operation will fail due to a conflict. This occurs because the specification of ScalarDB to manage transactions properly. Instead of reading the record explicitly, you can enable implicit pre-read. See Enable implicit pre-read forPut
operations for details.
This looks simple and users can know the details with Enable implicit pre-read for Put
operations.
Only one thing:
This occurs because the specification of ScalarDB to manage transactions properly.
This occurs because of the specification of ScalarDB to manage transactions properly.
seems a bit better.
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.
Okay, thank you. Let me fix with This occurs because of the specification of ScalarDB to manage transactions properly.
Thanks.
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.
Only one thing:
This occurs because the specification of ScalarDB to manage transactions properly.
This occurs because of the specification of ScalarDB to manage transactions properly.
seems a bit better.
Ah, sorry... I overlooked the grammar error... 🙇
I fixed my suggestion just in case!
When you update an existing record, you need to read the record by using `Get` or `Scan` before using a `Put` operation. Otherwise, the operation will fail due to a conflict. This occurs because ScalarDB assumes that another transaction wrote the record. Instead of reading the record explicitly, you can enable implicit pre-read. See [Enable implicit pre-read for `Put` operations](#enable-implicit-pre-read-for-put-operations) for details. | |
When you update an existing record, you need to read the record by using `Get` or `Scan` before using a `Put` operation. Otherwise, the operation will fail due to a conflict. This occurs because of the specification of ScalarDB to manage transactions properly. Instead of reading the record explicitly, you can enable implicit pre-read. See [Enable implicit pre-read for `Put` operations](#enable-implicit-pre-read-for-put-operations) for details. |
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.
Fixed in dfec35a. Thanks.
docs/api-guide.md
Outdated
.build(); | ||
``` | ||
|
||
Note that if you are certain that a record you are trying to mutate does not exist, you should not enable implicit pre-read for the `Put` operation for better performance. For example, if you load initial data, you should not enable implicit pre-read. A `Put` operation without implicit pre-read is faster than `Put` operation with implicit pre-read because the operation skips an unnecessary read. |
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.
For example, if you load initial data, you should not enable implicit pre-read.
I think load
fits a limited situation. insert a new record
or something sounds more general?
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.
I think load initial data
is an example of the situation where you are certain that a record you are trying to mutate does not exist. insert a new record
sounds too general and it's not an example to me. What do you think?
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.
I see. Your intention sounds reasonable 👍
I just thought "load" sounds to make a target state expected one. Insertions would be mainly used for that, but updates might be used. So, I slightly preferred explicitly mentioning insert
. But either sounds okay!
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.
LGTM! Thank you!
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.
LGTM! 👍
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.
Looking good! I've added some comments and suggestions. PTAL!
Co-authored-by: Josh Wong <joshua.wong@scalar-labs.com>
@josh-wong Thank you for taking at this! I've applied your suggestions. Please take a look again! |
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.
LGTM! Thank you!🙇♂️
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.
LGTM! Thank you!
Description
This PR disables implicit pre-read by default for
Put
operations because the feature is backward incompatible.Related issues and/or PRs
Changes made
Put
operationsChecklist
Additional notes (optional)
N/A
Release notes
N/A