I have a question regarding the read version. I appreciate it if you help me understand.
For read-write transactions, why we need to get the Read Version and why the database must return values with version no greater than the read version? I know this is for isolation, i.e., to make sure the transaction is reading the databases at a point in time defined by the read version. However, if the database does not return the most recent version while there is such a version, then the transaction is guaranteed to be aborted at the conflict checking time.
For example: suppose I have version 6 and 4 for a key. A transaction is assigned read version 5. When the client wants to read the key, the database returns version 4, as 6 is greater than 5. But by doing so, we know for sure the transaction will be aborted at the commit time because this transaction will be assigned a commit timestamp larger than any previously committed transaction, i.e. larger than 6 e.g. 7. So now we have a version with a timestamp less than 7 that is not read by the transaction. Thus, conflict checking will abort it.
Shouldn’t the client just read the most recent version that we have for each key? We shouldn’t worry about reading an inconsistent view; If there is any conflict, that’s fine, as the conflict checking will abort the transaction. On the other hand, if deliberately don’t return the most recent version, we guarantee that the transaction will abort.