fix: use payment initiation timestamp for stale PENDING detection#583
fix: use payment initiation timestamp for stale PENDING detection#583mostronator wants to merge 1 commit intomainfrom
Conversation
The stale PENDING cleanup was using the order's taken_at field to
determine staleness, but taken_at reflects when the order was taken
by a counterparty — not when the dev fee payment was initiated.
This caused:
- False positives: old orders with fresh payments flagged as stale
- False negatives: recent orders with stuck payments never cleaned up
Fix: encode the current unix timestamp in the PENDING marker itself:
PENDING-{order_id}-{unix_timestamp}
The stale detection now parses this timestamp from the marker and
compares it against the TTL, independent of order lifecycle timing.
- Legacy markers (PENDING-{id}) are treated as stale for backward compat
- 5 unit tests for timestamp parsing (UUID compat, legacy, edge cases)
Closes #570
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
closing via #584 |
Summary
Fixes stale PENDING detection to use the actual payment initiation timestamp instead of the unrelated
taken_atorder field.Closes #570
Problem
The stale PENDING cleanup query used
taken_at(when the order was taken by a counterparty) to determine if a PENDING dev fee entry is stale. This is wrong because:Solution (Option A from the issue — no schema change)
PENDING marker now includes timestamp
Stale detection parses timestamp from marker
Instead of a SQL
WHERE taken_at < cutoff, we now:PENDING-%rowsparse_pending_timestamp()Timestamp parsing
Since order IDs are UUIDs (containing dashes), the parser uses
rsplitto get the last segment and validates it's exactly 10 decimal digits (valid for unix timestamps 2001–2286), distinguishing it from UUID hex segments.Tests
5 new unit tests for
parse_pending_timestamp():Verification
cargo fmt— cleancargo clippy --all-targets --all-features— cleancargo test— 117 passed, 0 failed