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

kv,storage: omit MVCC timestamps for values read from intents of the current transaction #58046

Open
ajwerner opened this issue Dec 17, 2020 · 5 comments
Labels
A-kv-transactions Relating to MVCC and the transactional model. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-kv KV Team X-nostale Marks an issue/pr that should be ignored by the stale bot
Projects

Comments

@ajwerner
Copy link
Contributor

ajwerner commented Dec 17, 2020

Is your feature request related to a problem? Please describe.

The KV layer provides MVCC timestamps with data returned by reading requests. These MVCC timestamps power the crdb_internal_mvcc_timestamp (#51494). They are also used by the SQL layer to determine the validity interval of descriptor versions (#40793).

One oddity is that the timestamps carried on intents is volatile; transactions can get pushed and may commit with a later timestamp. Given that, it's not really safe to use that timestamp to power internals required for correctness and it's confusing for users of crdb_internal_mvcc_timestamp which observe their own writes.

Describe the solution you'd like

In order to avoid these hazards, the MVCC layer could omit populating the timestamps from values due to intents. Then, in the SQL layer which renders these timestamps, could convert the value to NULL.

Additional context

One thing to note is that I believe that we are (but soon won't be) doing something hazardous that was only subtly safe. In particular, we had a crash due to an assertion violation because when we re-resolve mutable descriptors inside a transaction we would set the ModificationTime to the provisional commit timestamp (#52358). That will be fixed in #56663 and bring back a bit of sanity.

In fact, now that I'm typing this, I'm a bit afraid we've got a bug lurking where we may populate the ModificationTime with a timestamp that precedes the commit timestamp. In practice, I'm hopeful that this could be okay, but I definitely have some concerns.

Jira issue: CRDB-3442

@blathers-crl
Copy link

blathers-crl bot commented Dec 17, 2020

Hi @ajwerner, I've guessed the C-ategory of your issue and suitably labeled it. Please re-label if inaccurate.

While you're here, please consider adding an A- label to help keep our repository tidy.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Dec 17, 2020
@ajwerner ajwerner added A-kv-transactions Relating to MVCC and the transactional model. and removed C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. labels Dec 17, 2020
@ajwerner ajwerner added this to Incoming in KV via automation Dec 17, 2020
@knz knz added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Dec 17, 2020
@knz
Copy link
Contributor

knz commented Dec 17, 2020

cc @nvanbenschoten @tbg for triage

@ajwerner
Copy link
Contributor Author

I'm putting this in the KV backlog even though the bulk of the business logic will be in the MVCC layer because, well, it's really about the implication to the KV protocol and not about the behavior of the MVCC layer. I'm still a bit unclear on what is owned by storage vs. kv when it comes to the MVCC code.

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@knz knz added X-nostale Marks an issue/pr that should be ignored by the stale bot and removed no-issue-activity labels Sep 5, 2023
@knz
Copy link
Contributor

knz commented Sep 5, 2023

still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-kv-transactions Relating to MVCC and the transactional model. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-kv KV Team X-nostale Marks an issue/pr that should be ignored by the stale bot
Projects
KV
On Hold
Development

No branches or pull requests

3 participants