Skip to content
Centriu
Centriu Helix

Rate Limit Enforcement Automation: A Counter Two Requests Could Both Read First

Centriu Helix's own rate-limit mechanism — the control capping how many times a specific action can happen within a given time window, per organization — tracked its own running count with a read-then-write pattern: read the counter's current value, add one to it in application logic, then write the new total back to the database as a separate step. That pattern leaves a real, exploitable window between the read and the write: if two or more requests arrive close enough together, each can read the identical starting count — say, a count of nine against a limit of ten — before either request's own write has actually landed, and each one independently concludes it is still under the limit and proceeds. The true number of actions actually let through in that window can exceed the configured limit by however many concurrent requests happened to land inside the gap, precisely under the load conditions a rate limit exists to protect against in the first place. The fix replaces the two-step read-then-write with a single atomic database operation — an insert that, on finding an existing counter for the same window, instead increments it in the same indivisible statement, using the counter's own underlying unique index to guarantee only one such operation can ever be in flight for a given (organization, scope, window) combination at a time. There is no longer a gap between reading a count and committing its increment for a second request to land inside.
Read-then-write could be raced
Now one atomic increment
Team monitoring live operational load
A counter two requests could both read first.

A limit is only as real as the atomicity of the count enforcing it

A rate limit's entire value comes from correctly answering, at the moment of each individual attempt, a very specific question: has the count for this window already reached the configured limit, right now? Reading the current count and writing back an incremented value as two SEPARATE steps quietly assumes nothing else can read or write that same counter in between — an assumption that holds under light, sequential load and breaks down under exactly the concurrent load a rate limit is built to constrain. The gap is not a logic error in how the limit is compared; it is a timing gap in how the count itself is updated.

How the underlying problem shows up before you fix it

A counter meant to enforce a hard limit is updated with a READ, followed by an application-level calculation, followed by a separate WRITE — rather than as one indivisible database operation.

Two or more requests arriving close enough together can each perform their own READ of the identical counter value before either one's own WRITE has been committed, each independently concluding the limit has not yet been reached.

The true number of actions actually allowed through in a short, concurrent burst can exceed the configured limit by roughly however many requests landed inside the read-write gap — the limit is not simply enforced a little late, it can be genuinely exceeded.

This class of defect is specifically the hardest to catch under ordinary, one-request-at-a-time testing, because a single request alone never has anything else to race against — it surfaces only under genuine concurrent load, which is exactly the condition the limit exists to protect.

A rate limit's own configured threshold and its own enforcement code can both be completely correct in isolation, while the STORAGE update connecting the two still leaves room for the limit to be exceeded — the three need to be checked together, not separately.

Why read-then-write feels correct until two requests actually overlap

Reading a value, changing it in familiar application code, and writing the result back is the most natural way to express "add one to this counter" — and for a system processing one request against a given counter at a time, it produces the exact right answer every time. The gap exists specifically because a database is a genuinely SHARED, concurrent resource: two requests hitting the identical rate-limit window at nearly the same instant are not a rare or exotic edge case for a real production system under real load, they are the ordinary, expected shape of legitimate traffic. A pattern that works perfectly under sequential testing has no way to reveal, on its own, that it silently assumes sequential access.

How Centriu Helix made its own rate-limit counter unable to be raced

Centriu Helix's own rate-limit mechanism previously incremented its counter with a read of the current value, an addition performed in application logic, and a separate write of the new total — three distinct steps, with a real window between the read and the write for a second, concurrent request to read the same starting value before the first request's own increment had been saved.

The fix replaces all three steps with a single atomic database function. It issues one `INSERT ... ON CONFLICT DO UPDATE` statement targeting the counter's own unique index (keyed on organization, scope, and time window): if no counter exists yet for that exact combination, one is created starting at one; if a counter already exists, it is incremented in the very same statement, using the database's own row-level locking to guarantee that only one such increment can ever be in flight for that specific counter at any instant. Whether ten concurrent requests arrive in the same window or one arrives every few seconds, each one's own increment is applied as a complete, indivisible step — there is no longer a gap in which a second request could read a stale, pre-increment value. A tenant guard on the same function additionally confirms the caller genuinely belongs to the organization it is incrementing a counter for (or is the platform's own trusted service-role path), since the function itself runs with elevated database privilege to perform the atomic write.

What is actually built today

Centriu Helix's rate-limit counter is incremented through a single atomic database operation — never a separate read, calculation, and write — closing the window where two concurrent requests could each read the same starting count.

The atomic operation relies on the counter's own unique index (organization, scope, time window) to guarantee only one increment can be in flight for a given counter at any instant, regardless of how many requests arrive concurrently.

A rate limit configured to allow, for instance, ten actions within a window can no longer be exceeded by concurrent requests racing the same read-then-write gap the previous implementation carried.

The same atomic function also records whenever an increment pushes a counter past its configured limit, keeping that evidence available without weakening or duplicating the limit's own enforcement.

This fix applies uniformly to every rate-limited action and every organization Centriu Helix's rate-limit mechanism governs, not to one specific limit in isolation.

A door that let in one extra guest for every person arriving at once (illustrative framing of the actual confirmed mechanism)

Before the fix, a limit of ten actions per window could, under genuine concurrency, let through more than ten — several requests arriving together could each read a count of nine and each conclude they were still under the limit, before any of their own increments had actually been saved. After the fix, the identical burst of concurrent requests is processed one atomic increment at a time — the tenth request sees the count already at ten and is correctly refused, no matter how tightly bunched the requests arrive.

What changes operationally

Centriu Helix's rate-limit counter is now incremented through a single atomic database operation rather than a separate read-then-write, closing a window where genuinely concurrent requests could each observe the same under-the-limit count and collectively exceed a configured rate limit by however many requests landed inside that gap.

When this is not the right fit

This automation covers specifically Centriu Helix's own rate-limit counter update. It is a distinct concurrency fix from this pillar's separate wave 92 page on a crashed worker's job lock never being reclaimed — that page concerns a lock becoming stuck and TOO restrictive after a crash; this page concerns a counter becoming exceedable and TOO permissive under concurrent load. Different tables, different failure directions, the same general class of read-then-write race.

Read-then-write vs. a single atomic increment

A read followed by a separate write is the simplest way to express an increment, and it is entirely correct for as long as nothing else can touch the same counter in between. Real, concurrent production traffic is exactly the condition where that assumption breaks — and a rate limit exists specifically to govern concurrent, bursty traffic, making it one of the worst possible places to rely on an increment pattern that assumes there is no concurrency at all. A single atomic database operation, using the counter's own unique index to serialize concurrent attempts at the database level itself, is the only version of the two that enforces the configured limit exactly, no matter how many requests arrive at once.

Related systems

Main system: Centriu Helix.

What it does NOT do

  • Does not change any rate limit's own CONFIGURED threshold — the fix corrects only how the counter enforcing an existing threshold is incremented, closing a gap that could let the true count exceed that threshold under concurrency.
  • Does not overlap with this pillar's separate wave 92 page on a crashed runner's job lock never being reclaimed — that concerns a lock becoming stuck (too restrictive); this concerns a counter becoming exceedable (too permissive) under concurrency, a different table and the opposite failure direction.
  • Does not retroactively identify how many requests, if any, may have exceeded a rate limit under concurrency before this fix — the fix prevents the class of defect from recurring going forward; a team needing a historical count would need its own dedicated review.
  • Does not add a new rate-limiting policy or change which actions are rate-limited — the fix corrects the atomicity of the counter update for Centriu Helix's existing rate-limit mechanism.
  • Does not extend this same atomic-increment pattern to any other counter in Centriu's other systems — this fix is specific to Helix's own rate-limit counter, confirmed to have carried this exact race.

Security and governance

Centriu Helix's rate-limit counter is now incremented through a single atomic database operation, closing a window where genuinely concurrent requests could each read the same pre-increment count and collectively exceed a configured limit. Full detail on this module's operational reliability and abuse-prevention practices lives at /governanca and /iso.

Pricing and contracting

Available by monthly subscription, with tiered plans. Values and terms come from the official pricing table at /precos (Centriu's central source — never restated here).

Frequently asked questions

Could this defect have made a rate limit block legitimate traffic too aggressively?

No — the defect made the limit too PERMISSIVE, not too restrictive. Under concurrency, more requests than the configured limit could get through; the fix does not change how many requests are allowed under ordinary, non-concurrent use.

How does the atomic version guarantee only one increment happens at a time for the same counter?

It uses a single `INSERT ... ON CONFLICT DO UPDATE` statement targeting the counter's own unique index — the database's own row-level locking on that index guarantees only one such statement can complete for a given counter at any instant.

Is this the same finding as the job-lock page on this site?

No — that page (wave 92) concerns a lock becoming permanently stuck after a crash, a too-restrictive failure. This page concerns a counter that could be incremented past its own limit under concurrency, a too-permissive failure. Different tables, different mechanisms, opposite failure directions.

Does this fix require lowering any configured rate limit as a mitigation?

No — the fix corrects how the counter enforcing an existing limit is updated. The configured limit itself is unchanged; it is simply now enforced exactly, even under concurrent load.

Who is allowed to call the new atomic increment function?

A caller must genuinely belong to the organization the counter is being incremented for, or be the platform's own trusted service-role path — checked explicitly inside the function itself, since the function runs with elevated database privilege to perform the atomic write.

What does Centriu Helix cost?

It is sold by subscription with a published starting price — exact current values are on the central pricing page.

See how Centriu Helix enforces a rate limit exactly, even under load

Reach our commercial team directly, or leave your details below — we'll follow up with guidance for your case.

Sources

  1. Centriu Helix — public product page — Centriu, 2026-07-20 · link(primária)
  2. Centriu Helix — public factsheet (API, JSON) — Centriu, 2026-07-21 · link
  3. Law No. 13,709/2018 — Brazil’s General Data Protection Law (LGPD) — Presidência da República (Brazil), 2018-08-14 · link

Last material update on .

By · AI-assisted production, with human review