Commit 7a75045a 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.
parent ea3af037
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment