-
Notifications
You must be signed in to change notification settings - Fork 244
Handle custom types with differing OIDs across shards #1280
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f2952fb
Handle custom types with differing OIDs across shards
sgrif a48c38f
Fix merge conflict, load all schema info in parallel
sgrif 6e1997d
Don't copy `RowDescription` bytes if we don't need to
sgrif 45fc504
Backfill more unit tests
sgrif 2c74be0
Canonical routing only happens with the new parser
sgrif 1f618dc
Reduce the amount of test churn
sgrif 575d880
Reset original bytes when rewriting Parse OIDs
sgrif d2b3401
Add an integration test for OID drift on simple query protocol
sgrif 933f1b3
s/sleep/safe_sleep
sgrif 751ffb6
regclass is not regtype
sgrif 8170856
Don't error when schema information is queried in direct-to-shard
sgrif b81ad83
Revert "Don't error when schema information is queried in direct-to-s…
sgrif fbfe50f
Include the type namespace in type oid lookup
sgrif 691f710
Use CancellationToken::run_until_cancelled
sgrif 8c2b60c
Rewrite `RowDescription` messages universally
sgrif a5e0382
Don't panic if OIDs aren't loaded
sgrif 014ce3d
Change OID canonicalization to a config option
sgrif 22eb27d
Final bits of cleanup
sgrif 5063961
Make clippy happy
sgrif 4e7abed
Don't hold server while awaiting canonical OIDs
sgrif 4ef9db1
Remove the fanciness
sgrif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
integration/rust/tests/integration/cross_shard_oid_drift.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| #![cfg(feature = "new_parser")] | ||
| use crate::setup::{admin_sqlx, connections_sqlx}; | ||
| use sqlx::postgres::types::Oid; | ||
| use sqlx::{Column, Executor, Row}; | ||
|
|
||
| #[derive(sqlx::Type, Debug, Clone, PartialEq)] | ||
| #[sqlx(type_name = "test_oid_drift_composite")] | ||
| struct Composite { | ||
| a: String, | ||
| b: String, | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_oid_drift() { | ||
| let conn = connections_sqlx().await.pop().unwrap(); | ||
| let admin = admin_sqlx().await; | ||
|
|
||
| // Intentionally cause the OID of the type to differ between shards | ||
| conn.execute("/* pgdog_shard: 0 */ CREATE SEQUENCE foo; DROP SEQUENCE foo;") | ||
| .await | ||
| .unwrap(); | ||
| conn.execute("DROP TYPE IF EXISTS test_oid_drift_composite CASCADE") | ||
| .await | ||
| .unwrap(); | ||
| conn.execute("CREATE TYPE test_oid_drift_composite AS (a text, b text)") | ||
| .await | ||
| .unwrap(); | ||
| conn.execute("DROP TABLE IF EXISTS test_oid_drift") | ||
| .await | ||
| .unwrap(); | ||
| conn.execute( | ||
| "CREATE TABLE test_oid_drift (customer_id BIGINT, composite test_oid_drift_composite)", | ||
| ) | ||
| .await | ||
| .unwrap(); | ||
| admin | ||
| .execute("SET canonicalize_type_information TO true") | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let composite = Composite { | ||
| a: String::from("a"), | ||
| b: String::from("b"), | ||
| }; | ||
| for i in 1..=20 { | ||
| sqlx::query("INSERT INTO test_oid_drift VALUES ($1, $2)") | ||
| .bind(i) | ||
| .bind(&composite) | ||
| .execute(&conn) | ||
| .await | ||
| .unwrap(); | ||
| } | ||
|
|
||
| let rows: Vec<Composite> = sqlx::query_scalar("SELECT composite FROM test_oid_drift") | ||
| .fetch_all(&conn) | ||
| .await | ||
| .unwrap(); | ||
| assert_eq!(rows, vec![composite.clone(); 20]); | ||
|
|
||
| let simple_rows = conn | ||
| .fetch_all("SELECT composite FROM test_oid_drift") | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let expected_oid: Oid = | ||
| sqlx::query_scalar("SELECT oid FROM pg_type WHERE typname = 'test_oid_drift_composite'") | ||
| .fetch_one(&conn) | ||
| .await | ||
| .unwrap(); | ||
| let given_oid = simple_rows.first().unwrap().column(0).type_info().oid(); | ||
| assert_eq!(given_oid, Some(expected_oid)); | ||
|
|
||
| let simple_data: Vec<Composite> = simple_rows.into_iter().map(|row| row.get(0)).collect(); | ||
| assert_eq!(simple_data, vec![composite; 20]); | ||
|
|
||
| admin.execute("RELOAD").await.unwrap(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.