Read at closed timestamp?

Is there any way to specifically read from the nearest replica at its current closed timestamp? Please correct me if I’m wrong, but it seems that if I do a follower read it will try to read at exactly at -x seconds. However, if the replica I’m talking to has a closed timestamp newer than that, it seems preferable to read there instead and wouldn’t mess up any consistency guarantees, right?

In the same vein, if I do a follower read at -4.8s with the intention of not making a trip to the leaseholder, what if my nearest replica has a closed timestamp older than that? Perhaps it’s not even possible for it to lag that much?

1 Like

It turns out this is complicated if the query is touching more than a single row. We are working on this actively. rfc: Bounded Staleness Reads by nvanbenschoten · Pull Request #66020 · cockroachdb/cockroach · GitHub.

2 Likes

Hi @alekseyfy, welcome to the forum! This isn’t my area of focus, but here’s my understanding:

Is there any way to specifically read from the nearest replica at its current closed timestamp? Please correct me if I’m wrong, but it seems that if I do a follower read it will try to read at exactly at -x seconds. However, if the replica I’m talking to has a closed timestamp newer than that, it seems preferable to read there instead and wouldn’t mess up any consistency guarantees, right?

No, CockroachDB doesn’t support reading from the nearest replica at its current closed timestamp. While I was typing my post up, I see that @ajwerner posted a link that explains the details.

In the same vein, if I do a follower read at -4.8s with the intention of not making a trip to the leaseholder, what if my nearest replica has a closed timestamp older than that? Perhaps it’s not even possible for it to lag that much?

That’s correct, if you use -4.8s it is guaranteed that the read can be served by a follower.

2 Likes