You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Table statistics collection uses inconsistent scan machinery which means
that we paginate over the table via separate transactions with
constantly advancing read timestamps. In particular, once we determine
that the current read timestamp is at least 5 minutes old (controlled
via `sql.stats.max_timestamp_age` cluster setting), we commit the
current txn and open a new one in which we advance the timestamp by the
amount of time that has passed since the start of the previous one (i.e.
by the duration of the previous txn).
This process requires an "initial timestamp" for the very first txn that
we use. That value comes from evaluating AS OF SYSTEM TIME clause of
CREATE STATISTICS stmt which happens when the job record is created.
Previously, if there was a long delay between the job record creation
and the job being actually executed, we would return "cannot specify
timestamp older than ..." error before creating the first txn. It's
unclear to me why this check was put in place since it's not really
necessary - we could simply remove it, which would make the very
first txn of the inconsistent scan to be committed right away, and
things would proceed easily.
This commit fixes this problem (by removing the check) but also improves
things a bit further by explicitly advancing the "initial timestamp"
before the first txn is open. If the initial timestamp is too old, it is
advanced to make its age to be 1/10 of the max timestamp age. An example
of the txn cycle:
```
current time: 100
initial timestamp: 50
max timestamp age: 10
time
100: advance initial timestamp to 99
100: start scan, timestamp=99
100-109: continue scanning at timestamp=99
109: bump timestamp to 108
109-118: continue scanning at timestamp=108
118: bump timestamp to 117
118-127: continue scanning at timestamp=117
```
Release note (bug fix): CockroachDB could previously encounter "cannot
specify timestamp older than ..." error during the table statistics
collection in some cases (like when the cluster is overloaded), and this
is now fixed. The bug has been present since 19.1 version.
0 commit comments