Skip to content

db: invalidate copied pooled connection handles on release - #29792

Merged
medvednikov merged 3 commits into
vlang:masterfrom
medvednikov:codex/issue-27668-20261009
Oct 9, 2026
Merged

medvednikov merged 3 commits into
vlang:masterfrom
medvednikov:codex/issue-27668-20261009

Conversation

@medvednikov

@medvednikov medvednikov commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Copying a pooled db.Conn copied its driver pointer while sharing its mutex. Releasing one copy left other copies able to use or return the physical connection after another borrower acquired it. Store the driver and mutex in shared private state so every copy becomes invalid together, and concurrent release/discard returns or closes the driver exactly once.

Add stale-copy and concurrent-copy regressions and document the release behavior. This addresses a safety gap in the existing pooling API discussed in #27668; the remaining multi-phase proposal is outside this change.

Validation:

  • Reproduced the stale-copy query against SQLite on unchanged master; the fixed copy returns db: connection is released.
  • Pool tests passed.
  • ./v -cstrict -cc clang -silent test vlib/db/pool_test.v vlib/db/tx_test.v vlib/db/driver_test.v passed (3/3).
  • Formatting, ./v check-md vlib/db/README.md, and git diff --check passed.

Refs #27668.

Focused validation at c4ef4adcc264 after the upstream merges: all five DB files remain byte-identical to fix 98eac560e538. Rebuilt the compiler after the first upstream compiler merge and passed strict Clang pool, transaction, and driver tests (3/3). The subsequent merge changed only doctor code/documentation and its fixture; the same three tests passed again with the compiler held stable. These checks use test drivers; live external database services were not exercised.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T03:28:46.644846Z c4ef4ad New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@medvednikov
medvednikov merged commit 99a8f78 into vlang:master Oct 9, 2026
25 of 95 checks passed
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.

1 participant