A pricing tool has a timed pair of jobs. In the evening, the nightly raise lifts a seller's prices for the night. In the morning, the return puts every price back. The return marks itself "done" when nothing is left to bring back.
One night the raise lifted 5,760 prices. The return ran, closed as "done", and 56 prices were still at the raised price. Nobody was told. The card said done.
Key facts
- The nightly raise lifted 5,760 prices. After the return said "done", 56 of them, about 1%, were still raised.
- Most of the 56 fell into three shapes: 25 rows counted "unchanged" as back, 2 rows were raised again by another job, 19 rows were never read.
- The first guess was wrong and cost time.
- Cause found and fixed on 2026-11-18. First night after the fix: 23 accounts, 6,804 prices raised, 0 left raised, 45 rows reported as held with a reason.
What happened
The raise ran on the night of 2026-11-17. The next morning the return ran, found "0 left", and closed. A check of the end state found 56 prices still at the value the raise had written.
The return had not crashed or timed out. It counted what it did, and what it did added up to zero left. The number was a statement about the job's own work, not about the prices at the marketplace.
Three shapes of a false done
Most of the 56 rows fell into three shapes. The remaining 10 are not broken down here.
1. "Unchanged" was counted as "undone" (25 rows). The return did not simply restore the saved old price. It asked the normal pricing rule for today's price. That rule looked at the market, and the market contained the seller's own raised offer. So the rule answered: the raised price is right. Old price equals new price, outcome "unchanged". The return counted every "unchanged" row as back, got 0 left, and closed.
2. The system echoed its own change back (2 rows). The return did lower these. A few hours later, an ordinary daytime pricing job raised them again. Its market data was a cached copy, up to 7 days old, that still showed the raised offer as a competitor. The daytime job had no memory that a raise had happened, so it read our own change as the market and followed it.
3. The return read a narrower set than the raise wrote (19 rows). These items went to 0 units in stock after the raise: sold, or on the way to the warehouse. The return read "rows with stock", a sensible filter for normal pricing. It never saw these rows, never counted them, and they kept the raised price at the marketplace.
None of these is exotic. Each is a normal pricing habit carried into a job that has a different question to answer. It is close to a guard that silently did not apply, but here the gap was in what "done" meant.
The first guess was wrong
The first guess was a setting: "a 'do not touch rows that are winning' tick is holding them up". It sounded right, because raised rows often look like winning rows. We checked and ruled it out. On these rows that tick is forced off, and 19 of the rows were never read at all, so no setting could have held them. The guess cost time. Counting rows against the end state, not reading settings, is what found the three shapes.
The fix
One change, four parts:
- Cap the recompute. On the return, a rule answer at or above the raised price never stands. The row goes to its saved price from before the raise.
- Held is not back. A row still at its raised price is "held, not back". The return tries again, and the card shows "N not back yet". After 3 passes it says stuck instead of done.
- Read what the raise wrote. The return reads the raise's own list of rows by id, including the ones at 0 stock.
- An echo guard. For 24 hours after a raise, no other job may send a row back up to its raised price.
A sketch, with made-up names:
// Before: read rows with stock, count what the job did.
const rows = await loadRows({ sellerId, inStock: true }); // stock > 0
for (const r of rows) r.outcome = await reprice(r); // "down" | "unchanged" | ...
// "unchanged" and "down" both count as back.
const left = rows.filter(r => r.outcome !== "unchanged" && r.outcome !== "down").length;
if (left === 0) markDone(); // 56 rows still raised
// After: read the raise's own ledger, check the end state.
// Every row the raise wrote, by id, 0 stock included.
const ledger = await loadLedger(raiseId); // { id, before, written }
for (const l of ledger) {
const answer = await reprice(l.id);
// A rule answer at or above the raised price never stands.
const target = answer >= l.written ? l.before : answer;
await setPrice(l.id, target);
}
// Done = no ledger row still at the value it wrote.
const stillUp = ledger.filter(l => current(l.id) >= l.written);
if (stillUp.length === 0) markDone();
else if (pass >= 3) markStuck(stillUp);
else showNotBackYet(stillUp.length); // try again next pass
| What | Before | After |
|---|---|---|
| Said done with | 56 prices still raised | 0 still raised |
| Rows the return read | Rows with stock | Every row the raise wrote, by id |
| "Unchanged" | Counted as back | Held, unless a named reason says otherwise |
| The card | "Done" | "N not back yet", stuck after 3 passes |
The first night after the fix: 23 accounts, 6,804 prices raised, 0 left raised after the return. 45 rows were reported as held with a reason, instead of being silently counted as done.
What anyone can apply tomorrow
"Done" for an undo is a statement about the end state, not about what the job did.
- Write a ledger. The do step records row id, value before, and value written. The undo works from that ledger, and nothing else decides its scope. Any filter the normal path uses (in stock, active, visible) is a way to lose rows.
- Finish on a query. Done means: rows from the ledger whose current value is still the written value equals 0. Outcomes like "unchanged" or "skipped" are not successes for an undo unless a named reason says so.
- Cap any recompute. If the undo recomputes instead of restoring, the new value may not be at or beyond the value being undone. Otherwise, fall back to the saved value.
- Guard against your own echo. Any reader of cached or third-party data that can contain your own write needs to know about that write for at least as long as the cache lives.
- Show stuck where done used to be. Put "N not back yet" and "stuck" on the same card that used to say done. A false done is worse than a visible stuck.
- Run a cheap alarm. A read-only script that lists every ledger row still at its written value, run the morning after.
Common questions
Why not always restore the saved price?
You can, and it is the simplest safe undo. Our return asks the pricing rule for today's price, and we kept that, with a cap: an answer at or above the raised price never stands, and the row goes to its saved price before the raise.
Why did "unchanged" look like success?
In normal pricing, unchanged means the price is already right, so there is nothing to do. The return borrowed that meaning. For an undo the question is different: is the row still at the value I wrote? An unchanged row that is still raised is the opposite of done.
Melta is free; get it on the App Store or Google Play.