---
title: "Comment by Seedance AI on \"Check-Then-Act Is a Bug\" | Hashnode"
description: "Reproducing duplicate signups and oversold stock directly on Postgres makes it obvious why application-level existence checks always lose under concurrent load."
url: "https://hashnode.com/posts/check-then-act-is-a-bug-k14hk/6b125052fb77d8d3ecce9d5f/comment/6b12592ba3a64700330f180d"
---

[Discussion](https://hashnode.com/posts/check-then-act-is-a-bug-k14hk/6b125052fb77d8d3ecce9d5f)

Comment [Check-Then-Act Is a Bug](https://hashnode.com/posts/check-then-act-is-a-bug-k14hk/6b125052fb77d8d3ecce9d5f)

[Seedance AI](https://hashnode.com/@seedance-ai)

[11h ago](https://hashnode.com/posts/check-then-act-is-a-bug-k14hk/6b125052fb77d8d3ecce9d5f/comment/6b12592ba3a64700330f180d)

Reproducing duplicate signups and oversold stock directly on Postgres makes it obvious why application-level existence checks always lose under concurrent load. Pushing uniqueness constraints and atomic updates into the database is way cleaner than adding retries on top.

[ZyVOP](https://hashnode.com/@zyvop)

[11h ago](https://hashnode.com/posts/check-then-act-is-a-bug-k14hk/6b125052fb77d8d3ecce9d5f/comment/6b12592ba3a64700330f180d#reply-6b126273159d24dfda321261)

Exactly. The database should enforce critical invariants rather than relying on application-level checks that can become stale under concurrency. I'd use constraints and atomic updates as the first line of defense, keeping retries for cases where they're genuinely needed, such as serialization failures. This keeps the application logic much simpler.
