Commit f81d6d77 authored by Dan Notestein's avatar Dan Notestein
Browse files

Restore advisory lock to prevent deadlock in hive_posts updates

The previous commit removed the advisory lock (777) between votes and posts
flush operations, reasoning that they update disjoint columns. However, CI
testing revealed this causes deadlocks:

  psycopg2.errors.DeadlockDetected: deadlock detected
  DETAIL: Process 581 waits for ShareLock on transaction 71798; blocked by process 579.
  Process 579 waits for ShareLock on transaction 71796; blocked by process 581.
  CONTEXT: while updating tuple (74,28) in relation "hive_posts"

While the columns are disjoint, both operations acquire row-level locks on
the same rows in hive_posts. When the same post receives both a vote and
a payout operation in the same batch, the two parallel transactions can
acquire locks in different orders, causing deadlock.

The advisory lock ensures serialization and prevents this deadlock scenario.

🤖 Generated with [Claude Code](https://claude.com/claude-code

)

Co-Authored-By: default avatarClaude <noreply@anthropic.com>
parent e5406776
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment