Understanding timestamp allocation

Hello All,

I am trying understand the timestamp allocation in crdb. I have run a basic transaction
T : b1 r1(x) w(x) r(y) w(y) c1.

I have “reply” printed in logs at replica_command/execute_cmd. Below are the timestamps I am seeing in the reply structure.

Things to notice :
According to my expectation all the reads and writes should at same timestamp (orig_timestamp).

  • But here r(w) and r(y) are hapenning at one timestamp (which is other than orig_timestamp)
  • there is no timestamp for w(x) and w(y)
  • commit is at orig_timestamp (as expected)

Can someone please explain me this behaviour ?

Follwing up questions

  1. I understand timestamps for the transaction is picked at trans_cored_sender. Am I right ?
  2. Transaction record is created on first write. So where is the timestamp picked for the first read (before any write) is stored ? Becuase that is used for other reads for transaction ?


Regarding the 2nd question.
The transaction timestamp is picked up when the KV-level Txn object (client.Txn) is initialized at the beginning of each (re)try cycle – see client/txn.go:516. From that point the txn timestamp is stored in memory, until the transaction records is written then it is also on disk.

Away from physical-clock problems, these schemes are able
to generate globally unique identification numbers for updates.

Are you sure about your link? This looks like you pasted a link to an unrelated web site.
Please fix the link, otherwise we will need to remove this post (we do not accept referrals to unrelated content).