Can version be used as a timestamp when i fetch a version from masterserver?

Hello, foundationdb hackers.

There is a small question about fdb_transaction_get_read_version.
I see from the masterserver’s source code that the read version is related with timestamp (us), and this read version as default options set will have 0.5s time skew, so can this api be used to get a monotonic timestamp?
Any suggestion about how to use it? And do i need to worry about the time skew like over 2s or upper when i fetch a version?

depending on what you want to achieve as the end goal.

There are two mechanisms to get monotonically increasing version:

  1. get_read_version is one approach.
  2. versionstamp is another approach to get the version when you commit a txn.
1 Like

@mengxu Great thanks for you reply, understand it.

Besides, i met a problem which get_read_version has more than 1s skew when i use default options about version.
situations like:

getversion a
sleep 7s
getversion b
---

b - a = 5.4s  or 8.5s

The fdb version is 7.1.23 and the whole cluster has only one fdbserver on one machine. And there were no other requests when i fetch the read version.
As i see from the masterserver’s getversion code, the version should be in [7-0.5, 7 + 0.5] when use default version options.

So it’s a little strange for me, is this a problem for masterserver’s getversion?

FDB version only guarantees it’s monotonically increasing.
You cannot use version to guess the time.
FDB recovery will bump the version by 5seconds as well.

1 Like