cockroachdb / cockroachdb/cockroach

'AS OF SYSTEM TIME' Can Read Incompatible Data

Open
#106,764 0 comments 0 reactions 0 assignees View on GitHub
A-cluster-upgrades A-sql-execution C-bug
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

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 https://github.com/cockroachdb/cockroach/issues/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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.