<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohamet Atef</title>
    <description>The latest articles on DEV Community by Mohamet Atef (@iammohamedatef).</description>
    <link>https://dev.to/iammohamedatef</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4202671%2Fcbe702d2-ba30-46b7-933f-8c3f07343723.jpeg</url>
      <title>DEV Community: Mohamet Atef</title>
      <link>https://dev.to/iammohamedatef</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iammohamedatef"/>
    <language>en</language>
    <item>
      <title>We intercepted PostgreSQL’s COMMIT completion and replayed the batch</title>
      <dc:creator>Mohamet Atef</dc:creator>
      <pubDate>Mon, 26 Oct 2026 12:17:49 +0000</pubDate>
      <link>https://dev.to/iammohamedatef/we-intercepted-postgresqls-commit-completion-and-replayed-the-batch-1olj</link>
      <guid>https://dev.to/iammohamedatef/we-intercepted-postgresqls-commit-completion-and-replayed-the-batch-1olj</guid>
      <description>&lt;p&gt;A write can commit and the caller still gets nothing back. From where the caller sits that looks like a failure. At the destination the work is done, so a second attempt that treats the first as failed ends up being a second mutation.&lt;/p&gt;

&lt;p&gt;While qualifying ImportFlow’s gateway design we wanted to know what a caller is left with in that state, so we forced it on purpose and looked at what the database and the gateway were holding afterwards.&lt;/p&gt;

&lt;p&gt;A 504 after the commit&lt;br&gt;
In an earlier hosted gateway qualification, a test-only fault returned HTTP 504 after the destination operation had already committed. The fault was injected on purpose, and a separate audit agent reproduced it on a disposable hosted Supabase project.&lt;/p&gt;

&lt;p&gt;The caller got HTTP 504. The test reported synthetic_response_lost_after_commit. The durable status showed one inserted row, and an independent SQL count found exactly one row in the table.&lt;/p&gt;

&lt;p&gt;So the caller was holding a 504 while the table held the data. If that client reads the 504 as “nothing was written” and sends the batch again, the second write lands on top of a finished one.&lt;/p&gt;

&lt;p&gt;Losing the COMMIT completion&lt;/p&gt;

&lt;p&gt;A gateway timeout loses a response above the database. Underneath it there’s a harder case, where PostgreSQL commits and the driver never hears about it. A later qualification round exercised that on PostgreSQL 17.6 by intercepting the actual COMMIT completion before the driver received it.&lt;/p&gt;

&lt;p&gt;caller sends batch&lt;br&gt;
-&amp;gt; destination commits&lt;br&gt;
-&amp;gt; COMMIT completion intercepted&lt;br&gt;
-&amp;gt; caller can't confirm the outcome&lt;br&gt;
-&amp;gt; fresh runtime recovers the original receipt&lt;br&gt;
-&amp;gt; replay performs no mutation&lt;/p&gt;

&lt;p&gt;The batch was a controlled upsert of three rows: one insert, one update and one row that didn’t change. Afterwards we looked at the destination revisions, the operation evidence and the effects of the transactional triggers.&lt;/p&gt;

&lt;p&gt;The original caller couldn’t confirm the outcome and reported reconciliation uncertainty. The transaction had committed. A fresh runtime then recovered the original durable receipt, with the original identity and time still on it. Replaying the batch performed no further mutation, and the revisions, the operation evidence and the trigger effects were all unchanged.&lt;/p&gt;

&lt;p&gt;Concurrent deliveries&lt;/p&gt;

&lt;p&gt;We also delivered the same logical batch identity concurrently. In the hosted evidence the deliveries converged on one durable row, and one hosted campaign with 50 duplicate deliveries gave every caller the retained outcome while the destination held a single row. In the later round we ran 2, 10 and 50 concurrent callers and saw a real PostgreSQL lock waiter during the runs. We didn’t use these runs for throughput numbers. The question was only whether the same logical batch could end up applied twice, and in the campaigns we ran it converged on one retained result.&lt;/p&gt;

&lt;p&gt;Same identity, changed content&lt;/p&gt;

&lt;p&gt;We reused a batch identity with different content as well. One version won and the other was rejected as a payload mismatch, and the retained receipt and result stayed as they were.&lt;/p&gt;

&lt;p&gt;What this changed for us&lt;/p&gt;

&lt;p&gt;The tests made us pull two things apart that retry code often merges. A transport attempt is an event on a wire, and it can fail, repeat or vanish after the destination has already acted. The logical write is what the user actually asked for. It needs a stable identity that survives retries, plus a durable record of its result.&lt;/p&gt;

&lt;p&gt;With both, a caller that lost the acknowledgement has something to ask, which is what happened to this logical write. In the path we tested, the answer was already sitting at the destination as a durable receipt and retained destination state.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>database</category>
      <category>backend</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
