Skip to content

Commit

Permalink
XXX: Hack statement ID to be random instead of sequential
Browse files Browse the repository at this point in the history
Use random statement IDs instead of sequence to avoid conflicts (almost
100% of the time). This obviously is not the solution to the problem.
It is only the proof of concept to verify that this is the root cause
of the problem.
  • Loading branch information
mareq committed Mar 9, 2022
1 parent dfd9cf5 commit a74e03f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sqlx-core/src/postgres/connection/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ async fn prepare(
metadata: Option<Arc<PgStatementMetadata>>,
) -> Result<(u32, Arc<PgStatementMetadata>), Error> {
let id = conn.next_statement_id;
conn.next_statement_id = conn.next_statement_id.wrapping_add(1);

// XXX(mq): Use random statement IDs instead of sequence to avoid conflicts (almost
// 100% of the time). This obviously is not the solution to the problem.
// It is only the proof of concept to verify that this is the root cause
// of the problem.
//conn.next_statement_id = conn.next_statement_id.wrapping_add(1);
conn.next_statement_id = rand::thread_rng().gen();

// build a list of type OIDs to send to the database in the PARSE command
// we have not yet started the query sequence, so we are *safe* to cleanly make
Expand Down

0 comments on commit a74e03f

Please sign in to comment.