chore(devex): flag hot parent row locks - #89930
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
🤖 CI report
|
webjunkie
left a comment
There was a problem hiding this comment.
We could probably steer towards using the XYZConfig models that map 1:1 to Team? Or are these also hot tables?
I am not nearly as deep in this codebase as you are, but having glimpsed at it - yes that looks like a good pattern! Then lock contention would at most be limited to everyone that uses the same XYZConfig and not everyone that interacts with the global Team. That would severely reduce possible blast radius. It can still cause an issue if all of this happens on the same pgbouncer and it runs out of connections and such, but it's a lot less likely, so it'd be a pretty good improvement regardless imo |
Problem
Developers and coding agents can introduce broad write contention when they use
TeamorOrganizationrows as local mutexes.PostgreSQL foreign-key checks can take
KEY SHARElocks on parent rows.FOR UPDATEconflicts with those locks, so unrelated child writes can wait.Changes
FOR NO KEY UPDATE, which remains compatible with foreign-keyKEY SHARElocks.Examples for DevEx review:
assign_slotcreate_with_numbercreate_unlisted_dashboardensure_managed_warehouse_direct_source_persist_columnscreate_workflow_taskThis change is mechanical and has no user-visible effect.
How did you test this code?
uvx semgrep --test --config .semgrep/rules/devex .semgrep/rules/devexcovers direct and chained locks, safeno_key=Truecalls, unrelated models, and justified suppression.hogli ci:preflight --fixcompleted without failures.👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Automatic notifications
Docs update
Updated root
AGENTS.mdwith PostgreSQL parent-row locking guidance for coding agents.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
OpenAI Codex in OMP authored the rule, fixture, guidance, and draft PR. Skills used:
/writing-code-comments,/writing-tests,/writing-user-facing-copy,/running-ci-preflight,/writing-pr-descriptions, and/reviewing-before-pr.The Greptile CLI was unavailable locally, so the harness fallback reviewer checked the committed diff. It found two false positives:
no_key=Trueand test-module paths. Both were fixed before this PR opened. No private operational data or session-derived examples appear in this public change.