• footfaults@lemmygrad.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    20 hours ago

    Here’s what frustrates me about all these “Postgres is all you need” kinds of posts. Most of the design decisions, the backing store for the data is only a small piece of the overall puzzle. It’s an important part, but still, just saying, for example, that you don’t need to use Kafka, just store it in Postgres misses a whole lot of the reasons why you would use something like Kafka.

  • TehPers@beehaw.org
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 day ago

    The article fails to actually explain how to do durable workflows in Postgres:

    In a Postgres-backed durable workflows system, application servers directly communicate with Postgres to execute workflows instead of going through a central orchestrator. A client submits a workflow for execution by creating an entry for it in a Postgres workflows table. Application servers poll the table for workflows to dequeue and execute. As a server executes a workflow, it checkpoints the output of each step to Postgres. If a server executing workflows crashes or fails, another server can recover its workflows from their checkpoints.

    What you want are a locking clause (FOR UPDATE for example) to “acquire” an item from your queue and SKIP LOCKED to skip over rows that are being processed. Contrary to what you’d normally do, you’d hold a long-running transaction which maintains a lock on the row you’re processing, then on completion either commits (success) or rolls back (failure) its changes to that row.

    You also don’t want to poll. Use LISTEN instead.