-
Notifications
You must be signed in to change notification settings - Fork 323
Clarified the order of watch events for TXN operations #984
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
base: main
Are you sure you want to change the base?
Conversation
Hi @socketpair. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Don't know if this is something that we want users to depend on. |
/ok-to-test |
@serathius This is exceptionally important. For example, TXN are used to ensure uniqueness of something, i.e. if one wants to change something, he might do a single TXN that erases something and adds another record. So, if a watcher first sees adding and only then erasing, it may face a uniqueness problem updating a cache inside an app. Actually, I faced exactly this issue in my app. |
If we want the user to depend on this, we should probably add test coverage in the robustness tests. |
@siyuanfoundation I don't know how to make a test for this case. We need to check that etcd DOES NOT reorder. But since a test writer doesn't know WHEN it may reorder — it is difficult to trigger. AFAIK (now) etcd has subrevisions that guarantee the order. But we don't have a public API to access them. A simple test that issues an TXN, and watches it comparing the order - possible. But for me almost useless. Finally, I think the doc should be merged, and another issue regarding testcase should be created. |
I just fixed DCO |
Watcher should apply a single revisions atomically. Exposing partial state in cache is the problem, not etcd documentation. |
@serathius it does. But in order to accomplish this, the watcher typically should sort events while applying. For example, if the cache is an SQL db. Yes, in single SQL transaction. But the order inside it is important because of integrity rules in the DB. But if etcd guarantees the order, the etcd changer might issue correct TXNs that do not require sorting in watchers. Next, since subrevisions exist, what was the intention? And also, if the order is not guaranteed in etcd here, we need to state this. If yes - state that preserved. I think, that order guarantees should be stated. |
@serathius @spzala @siyuanfoundation |
@serathius @spzala @siyuanfoundation Ping. Who is supposed to decide if the order should be documented or not ? Again, I strongly think that should be documented. |
@serathius @spzala @siyuanfoundation ping again |
1 similar comment
@serathius @spzala @siyuanfoundation ping again |
@socketpair I'm going to discuss this at an upcoming community meeting. |
We discussed this in the Etcd community meeting. The consensus was that the order of events inside a transaction is NOT guaranteed (we already do some skipping of duplicate operations) and might be even less guaranteed in the future (e.g., consider an implementation of efficient batch writes). @serathius any comments? |
@serathius any comments? No, I agree. Thanks for clearing it out. |
Okay.
|
Imagine that inside a transaction you add a key, then delete the same key, and then add it again. Benjamin was saying we do some skipping for that, and we might do more in the future (because it's good for performance). @ahrtr ?
What would the PR consist of, then? Pretty much the change you made here is to say that we will guarantee it. |
Regarding duplicates:@jberkus it is impossible. Because keys in txn action list can not intersect or be non-unique. Regardig doc: I want to state in the doc, that watchers should not rely on the order of operations in TXN actions blocks. P.S. Something not very clear. |
Probably I did not say it clearly in yesterday's community meeting, also I didn't know this conversation at that time.
Example: a TXN contains three put operations
|
@ahrtr huge thanks for explanations. What you think about these fixes:
If yes, I would fix |
Basically YES. For the "
also cc @serathius |
@ahrtr @jberkus @serathius @spzala @siyuanfoundation please review |
content/en/docs/v3.6/learning/api.md
Outdated
For transactions without nested TXNs, the order of execution of operations | ||
is guaranteed to be the same as in its list of operations, which means stable | ||
GET responses within the transaction and the same order of watch events. | ||
For transactions with nested TXNs, the order of execution is not specified. | ||
|
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 it's better to clarify all guarantees in one place (the api_guarantees.md
doc). This comment applies to all other versions as well (3.5 and 3.4).
For transactions without nested TXNs, the order of execution of operations | |
is guaranteed to be the same as in its list of operations, which means stable | |
GET responses within the transaction and the same order of watch events. | |
For transactions with nested TXNs, the order of execution is not specified. |
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
Please note that only 3.4, 3.5 and 3.6 are supported versions. Suggest not to update older versions < 3.4. |
@ahrtr fixed. please review |
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 & thx
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, socketpair The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@ahrtr sorry, During changes I forgot about stable GETs. Fixed. Please look again.. |
@ahrtr done, and also rebased, added to v 3.7 as well. Please review. |
Signed-off-by: Korenberg Mark <[email protected]>
has already been posted. | ||
has already been posted. For transactions without nested TXNs, the order of | ||
generated events is guaranteed to be the same as in its list of operations. | ||
For transactions with nested TXNs, the order of generated events is not |
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.
Again I'm against about over specifying this. Users should apply single revisions atomically and not depend on order of operations within a TXN.
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.
To be more specific, I don't care about enough to argue. But don't expect me to help maintain a guarantee that is useless and has zero testing and might impede development/optimization of etcd in the future.
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.
that is useless
Why do you think it's useless? Read the 3rd item in #984 (comment). Also FYI in a broader database industry, the order of commands in one transaction is guaranteed by MVCC/visibility check.
has zero testing
I agree it's a gap that we need to resolve.
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.
Also FYI in a broader database industry, the order of commands in one transaction is guaranteed by MVCC/visibility check.
We should not compare etcd TXN with database transactions, it's closer to single UPDATE statement with WHERE condition. When I execute a UPDATE
request on SQL database I don't know nor care in which order the rows were updated.
This is because in both cases such operation should not touch a single row/key twice.
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 I execute a
UPDATE
request on SQL database I don't know nor care in which order the rows were updated.This is because in both cases such operation should not touch a single row/key twice.
It seems that we are not talking the same thing. We are discussing the execution order of commands/operations in one transaction, not the the about data/rows the commands are updating.
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.
We should not compare etcd TXN with database transactions
SQL databases typically don't have modification notifications. It would be nice if Etcd could send ONE BIG event for whole TXN transactions. But it's not so! Instead, it sends a sequence of events. Yes, with revisions, but a sequence (!). That's why I want the order to be clarified.
it's closer to single UPDATE statement with WHERE condition
Yes, but we have GET requests in TXN list of operations.
@serathius I can write something like "It's strongly advised to interpret all events generated by a single TXN as a whole, not depending on the order of events". Are you OK with this ? |
For all reference, actually the etcd official document already clarifies this, https://etcd.io/docs/v3.6/dev-guide/api_reference_v3/
|
Feels like we need to discuss this in a community meeting again. This is the regular etcd community meeting, or triage meeting. |
Added to agenda for today's community meeting |
To summary my thoughts/points:
|
It is hard to imagine |
etcd-io/etcd#19736 (reply in thread)