Tagged: PostgreSQL

3 posts tagged “PostgreSQL”.

Topics

Posts3 notes

  1. CHECK constraints guard states, not transitions

    A CHECK constraint can't stop a finished CI run from going back to queued, because it only sees the new row. A conditional UPDATE can. Here's the compare-and-swap pattern in Postgres, the read-then-write version that let 19 of 20 goroutines win, and two type errors along the way.

    6 min read · PostgreSQL, Go, Architecture

  2. A Postgres job queue in one statement, and what breaks when you remove each part

    UPDATE ... WHERE id = (SELECT ... FOR UPDATE SKIP LOCKED) is the standard Postgres job queue. I removed its parts one at a time: duplicate claims, workers that think the queue is empty, and a queue that runs in single file.

    6 min read · PostgreSQL, Go, Distributed Systems

  3. A missing `tx` deadlocked my service, and my test just hung

    I broke a Postgres transaction on purpose and expected a red test. The test hung instead. One query that skipped the transaction made every pool connection wait on another, and Postgres had no way to tell.

    5 min read · Go, PostgreSQL, Reliability

← All posts