-
Notifications
You must be signed in to change notification settings - Fork 4.1k
'AS OF SYSTEM TIME' Can Read Incompatible Data #106764
Description
Describe the problem
The 'AS OF SYSTEM TIME' clause allows users to pick the logical timestamp to execute a query at. When running 'AS OF SYSTEM TIME' queries, sql uses descriptors from the provided timestamp. This could cause problems when combined with serial major version upgrades and migrations.
Consider the 22.1, 22.2, and 23.1 upgrade chain. 23.1 is not guaranteed to be compatible with 22.1 descriptors.
Example:
t0: cluster is running 22.1
t1: binary is upgraded to 22.2
t2: 22.2 migrations are run
t3: binary is upgraded to 23.1
t4: 23.1 migrations are run
t5: A query is run with a system time of t0.
In this example the 23.1 query would try to interpret the descriptors from t0, which may cause the query to return incorrect results.
This problem could impact any sub system that depends on version gates and migrations. See #106762 for an example that is not dependent on descriptors.
The easiest way to "fix" this problem would be to reject AS OF SYSTEM TIME queries that attempt to read logical timestamps that were written by a binary older than clusterversion.BinaryMinSupportedVersionKey.
Jira issue: CRDB-29708