Skip to content

fix: qualify created_at in the PostgreSQL conversation upsert - #481

Merged
maralbahari merged 1 commit into
vllm-project:mainfrom
Zheng-Lu:fix/479-postgres-conversation-upsert
Oct 26, 2026
Merged

maralbahari merged 1 commit into
vllm-project:mainfrom
Zheng-Lu:fix/479-postgres-conversation-upsert

Conversation

@Zheng-Lu

Copy link
Copy Markdown
Contributor

Summary

Fixes #479.

On PostgreSQL, every stored conversation turn returned 500 before inference ran. The turn calls conversation::get_or_create, whose upsert ends in ON CONFLICT (id) DO UPDATE SET created_at = created_at. In that clause an unqualified created_at could mean the existing row or EXCLUDED, so PostgreSQL rejects the statement as ambiguous (SQLSTATE 42702). SQLite accepts it.

The update now reads SET created_at = conversations.created_at. It is still a no-op whose only job is to make RETURNING yield the existing row. DO NOTHING would not work here, because it returns no row on conflict. This is the only ON CONFLICT in production code.

CI's postgres job already runs postgres_storage_integration, so the new test runs there without any workflow change.

Test Plan

  • New postgres_get_or_create_creates_then_returns_the_existing_conversation in postgres_storage_integration.rs:
    1. The first get_or_create creates the conversation, and a turn is persisted into it.
    2. The second call returns the same conversation and created_at.
    3. The conversation version (including latest_response_id) and its item are unchanged.
  • RED on a7dc7b5 against postgres:17-alpine: the first call fails with 42702 column reference "created_at" is ambiguous.
  • GREEN with the fix. All three of CI's PostgreSQL steps pass locally against postgres:17-alpine:
    • storage::schema::tests:: (3);
    • postgres_storage_integration (6, including the new test);
    • postgres_tenant_isolation_test (6).
  • End to end: while reviewing feat: add DELETE /v1/responses/{id} and GET /v1/responses/{id}/input_items #466 against PostgreSQL, a POST /v1/responses turn with conversation returned this 500. With the same one-line change, the turn and that PR's conversation listing test passed.
  • The SQLite test_conversation_get_or_create_same_id still passes.
  • cargo fmt -- --check, cargo clippy --workspace --all-targets -- -D warnings, the Rust file-size ratchet and pre-commit run --all-files are clean.
  • cargo test --workspace --no-fail-fast: 111 test binaries ran, with 2719 tests passing and 1 failing. The failure is tool::web_fetch::http::tests::the_deadline_bounds_a_slow_origin, a wall-clock bound in code this PR doesn't touch. It also fails on main on my machine when the whole suite runs in parallel, and it passes 3 of 3 runs in isolation.

conversation::get_or_create ran `ON CONFLICT (id) DO UPDATE SET
created_at = created_at`. PostgreSQL rejects the unqualified column as
ambiguous with EXCLUDED.created_at (42702), so every stored conversation
turn returned 500 on PostgreSQL. SQLite accepts it.

Qualify it as conversations.created_at and add a PostgreSQL test that
creates a conversation, stores a turn, and gets it again unchanged.

Fixes vllm-project#479

Signed-off-by: Zheng Lu <[email protected]>

@maralbahari maralbahari left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@maralbahari
maralbahari merged commit 52f32e1 into vllm-project:main Oct 26, 2026
15 checks passed
haoshan98 added a commit to EmbeddedLLM/agentic-api that referenced this pull request Oct 27, 2026
Brings in vllm-project#480 (ARCHITECTURE.md request admission and rate limiting),
vllm-project#481 (PostgreSQL conversation upsert), vllm-project#467 (prompt cache breakpoints on
inlined text files), vllm-project#478 (benchmark session sweep) and vllm-project#487 (test
alignment with typed Responses validation). Merged without conflicts.

Signed-off-by: haoshan98 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: stored conversation turns return 500 on PostgreSQL (ambiguous created_at in get_or_create)

2 participants