Skip to content

[ConnMgr] Bind packet can get skipped for unnamed prepare stmt if backend has another client's unnamed prepare statement #29935

@arpit-saxena

Description

@arpit-saxena

Jira Link: DB-19788

Description

This issue was discovered in 2024.2.7.1-b1 and is not present in 2024.2.4.0-b89. This is a regression introduced by 7a96483

This can happen when these conditions are met:

  • Bind on unnamed prepared statement has been sent by client
  • On the attached physical backend, unnamed prepared statement has been prepared by some other client

In this scenario, Bind packet is not forwarded to the backend (!!). This was missed because earlier code was using some logic setting a forwarded variable, which was removed in the Odyssey commit which we were picking. However, there was a subtle use of it in the code we had subsequently added after forking -- to forward the Bind packet in case of unnamed prepared statement.

I haven't been able to repro this issue with pgx driver's high level APIs -- it always seems to send Parse again for an unnamed prep statement, and the optimization for avoiding Parse only happens with named prep statements. I have reproduced this code using a lower level API which pgx also provides which can be used to control which packets to send. Here's a GitHub Gist with the repro

Verified that backends crash on running the repro on 2024.2.7 and don't crash on 2024.2.4

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions