2
$\begingroup$

I'm reading the paper An Empirical Evaluation of In-Memory Multi-Version Concurrency Control which is about implementations of MVCC for in-memory databases. Section 3.3 on Two-phase Locking (MV2PL) says:

To perform a read operation on a tuple A, the DBMS searches for a visible version by comparing a transaction’s T-id with the tuples’ begin-ts field. If it finds a valid version, then the DBMS increments that tuple’s read-cnt field if its txn-id field is equal to zero (meaning that no other transaction holds the write lock)

Here is the image in Figure 2c: MV2PL

The confusion point is about how it actually does this operation atomically: Read location A (txn-id), if its value is equal to 0 then increment location B (read-cnt)

Atomic operation in C/C++ does compare-and-swap only for a single memory location, however, in this case we are dealing with two memory locations. Is there any other CPU intrinsic for this operation, or another trick is employed?

$\endgroup$

1 Answer 1

1
$\begingroup$

I asked the question directly from paper authors, and they replied to me:

txn-id and read-cnt are 4-bytes each (not 8 bytes as I thought before), thus it is possible to compare-and-swap in one step.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.