Open
Description
Hello! I've been using sqlx
to talk to CockroachDB databases and recently started an upgrade from sqlx-0.3.5
to sqlx-0.4.2
. After upgrading, many tests began to fail with
PgDatabaseError {
severity: Error, code: "0A000",
message: "unimplemented: multiple active portals not supported",
detail: None,
hint: Some("You have attempted to use a feature that is not yet
implemented.\nSee: https://go.crdb.dev/issue-v/40195/v20.1"),
position: None,
where: None,
schema: None,
table: None,
column: None,
data_type: None,
constraint: None,
file: Some("distsql_running.go"),
line: Some(775),
routine: Some("init")
}
I came up with a minimal reproducing test case that does a SELECT 1
. When this query is executed within a transaction, it fails. But if I run the query directly against the postgres connection pool, it succeeds.
#[tokio::test]
async fn test_sqlx_transaction() -> Result<(), sqlx::Error> {
let pool = PgPoolOptions::new()
.max_connections(5)
.connect("postgres://root@localhost:26257/api_server")
.await?;
let mut txn = pool.begin().await.expect("should get txn");
let row: (i64,) = sqlx::query_as("SELECT $1")
.bind::<i64>(1)
.fetch_one(&mut txn)
.await
.expect("query_as error");
txn.commit().await.expect("txn should commit");
println!("row.0: {}", row.0);
Ok(())
}
Both cases succeed for sqlx-0.3.5
.
I was told in the CockroachDB community slack that my database driver is trying to have multiple active result sets (portals) concurrently on the same connection. I'm not sure where to go from there. Thanks for any ideas! I'm happy to work on a patch, given some clues, if you have ideas about what is happening.