-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
Read-only requests that qualify for dropping latches early scan the lock table under latches to perform conflict resolution. If they don't conflict with any concurrent transactions, they drop their latches and scan the MVCC keyspace. However, if a request is trying to read a key that was written to in its transaction, we may need access to the key's intent history when performing the scan. If scanning the lock table uncovers an intent by our own transaction, we need access to the intent history if: 1. The request is reading at a lower sequence number than the found intent's sequence number. 2. OR the request is reading at a strictly lower timestamp than the intent's timestamp. 3. OR the found intent should be ignored because it was written as part of a savepoing which was subsequently rolled back. 4. OR the found intent and read request belong to different txn epochs. Prior to this patch, we weren't accounting for 3 and 4. Worse yet, our determination for 2 was a less than equal to -- which meant we would end up consulting the intent history in the common case. This meant that existing tests which would have exercised 3 and 4 weren't failing on us. Instead of correcting the determination, this patch makes it such that all read-your-own-write transactions consult intent history. This avoids the subtle complexity of getting all these cases right and keeping them in sync with the MVCC code that reads keys. It also seems like scanning the lock table twice (once during conflict resolution and once during the MVCC read) for read-your-own-write transactions in the common case did not cause noticable regressions. We can always optimize this later, if we find there's a need to. Epic: none Fixes: #94337 Release note: None
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Regression test for https://github.com/cockroachdb/cockroach/issues/94337. | ||
statement ok | ||
CREATE TABLE a (id INT); | ||
|
||
statement ok | ||
BEGIN | ||
|
||
statement ok | ||
SELECT pg_sleep(1.5) | ||
|
||
statement ok | ||
SAVEPOINT s | ||
|
||
statement ok | ||
SELECT pg_sleep(1.5) | ||
|
||
statement ok | ||
INSERT INTO a(id) VALUES (0); | ||
|
||
statement ok | ||
ROLLBACK TO SAVEPOINT s | ||
|
||
query I | ||
SELECT * FROM a | ||
---- | ||
|
||
statement ok | ||
COMMIT |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.