Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: Include system indexes in read transactions #21820

Merged
merged 14 commits into from
Sep 21, 2023
5 changes: 5 additions & 0 deletions src/adapter/src/coord/introspection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ pub fn auto_run_on_introspection<'a, 's, 'p>(
return TargetCluster::Active;
}

// Auto-routing mid transaction can cause an abort due to an invalid timedomain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does one of the added tests cover this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added one. I meant to comment that some tests were failing without this because a bunch of pg_catalog queries get auto-routed and then fail mid-transaction.

if session.transaction().is_in_multi_statement_transaction() {
return TargetCluster::Active;
}

// These dependencies are just existing dataflows that are referenced in the plan.
let mut depends_on = depends_on.into_iter().peekable();
let has_dependencies = depends_on.peek().is_some();
Expand Down
11 changes: 7 additions & 4 deletions test/sqllogictest/timedomain.slt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ SELECT * FROM t;
statement ok
ROLLBACK

# Test that user table and system tables can be mixed in a transaction.
# Test that user table and mz_catalog system tables cannot be mixed in a transaction because they
# belong to different timedomains.

statement ok
BEGIN;
Expand All @@ -75,11 +76,13 @@ query I rowsort
SELECT * FROM t
----

statement ok
SELECT * FROM mz_views
# This may stop failing in the future if a view in pg_catalog starts to depend on this. In that case
# just change this query to select from an object that isn't referenced from pg_catalog.
query error Transactions can only reference objects in the same timedomain.
SELECT * FROM mz_internal.mz_show_default_privileges

statement ok
COMMIT
ROLLBACK

# Test that timeline dependent queries can be included in transaction.

Expand Down