Remove HeapTuple and Buffer dependency for predicate locking functions
Ashwin Agrawal <aagrawal@pivotal.io>
From: Ashwin Agrawal <aagrawal@pivotal.io>
To: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Date: 2019-06-24T17:41:06Z
Lists: pgsql-hackers
Attachments
- v1-0001-Remove-HeapTuple-dependency-for-predicate-locking.patch (text/x-patch) patch v1-0001
Proposing following changes to make predicate locking and checking functions generic and remove dependency on HeapTuple and Heap AM. We made these changes to help with Zedstore. I think the changes should help Zheap and other AMs in general. - Change PredicateLockTuple() to PredicateLockTID(). So, instead of passing HeapTuple to it, just pass ItemPointer and tuple insert transaction id if known. This was also discussed earlier in [1], don't think was done in that context but would be helpful in future if such requirement comes up as well. - CheckForSerializableConflictIn() take blocknum instead of buffer. Currently, the function anyways does nothing with the buffer just needs blocknum. Also, helps to decouple dependency on buffer as not all AMs may have one to one notion between blocknum and single buffer. Like for zedstore, tuple is stored across individual column buffers. So, wish to have way to lock not physical buffer but logical blocknum. - CheckForSerializableConflictOut() no more takes HeapTuple nor buffer, instead just takes xid. Push heap specific parts from CheckForSerializableConflictOut() into its own function HeapCheckForSerializableConflictOut() which calls CheckForSerializableConflictOut(). The alternative option could be CheckForSerializableConflictOut() take callback function and callback arguments, which gets called if required after performing prechecks. Though currently I fell AM having its own wrapper to perform AM specific task and then calling CheckForSerializableConflictOut() is fine. Attaching patch which makes these changes. This way PredicateLockTID(), CheckForSerializableConflictIn() and CheckForSerializableConflictOut() functions become usable by any AM. 1] https://www.postgresql.org/message-id/CAEepm%3D2QbqQ_%2BKQQCnhKukF6NEAeq4SqiO3Qxe%2BfHza5-H-jKA%40mail.gmail.com
Commits
-
Remove dependency on HeapTuple from predicate locking functions.
- 6f38d4dac381 13.0 landed
-
Optimize PredicateLockTuple().
- db2687d1f378 13.0 landed
-
Optimize TransactionIdIsCurrentTransactionId().
- 695c5977c8bc 13.0 landed
-
Fix predicate-locking of HOT updated rows.
- 54c98fa71ac1 9.4.25 landed
- fd298cd6394b 9.5.20 landed
- 75774cc221e5 9.6.16 landed
- 65468cc705ea 10.11 landed
- c5b796125299 11.6 landed
- f8d30182b121 12.0 landed
- 1169fcf129f4 13.0 landed
-
Introduce logical decoding.
- b89e151054a0 9.4.0 cited
-
Fix bugs in SSI tuple locking.
- 81fbbfe3352d 9.4.0 cited
-
Implement genuine serializable isolation level.
- dafaa3efb75c 9.1.0 cited