Skip to content

CancelRequest always decode message as PROTOCO 3.2 version #440

@tbicr

Description

@tbicr

https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-CANCELING-REQUESTS describes that cancel protocol has different flow that standard connection ie. it sends CancelRequest instead StartupMessage, so no protocol_negotiation on startup is called and default protocol (3.2) is applied.

As result all cancel_request in CancelHandler.on_cancel_request come as SecretKey::Bytes. This bring some inconsistency when on startup we can use protocol 3.0 SecretKey::I32, but in CancelHandler.on_cancel_request always get protocol 3.2 SecretKey::Bytes, so without additional normalization secret_key in startup and on_cancel_request will not match.

As I understand pgwire has no decision about CancelRequest decoding, and it fully rely what client send.

Potentially there are no reason to have SecretKey enum at all and always use bytes for secret_key.

pub enum SecretKey {
    I32(i32),
    Bytes(Bytes),
}

Moreover CancelRequest protocol 3.2 looks binary compatible with 3.0:

CancelRequest (F)
  Int32
  Int32(80877102)
  Int32
  Byten

vs

CancelRequest (F)
  Int32(16)
  Int32(80877102)
  Int32
  Int32

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions