Skip to content

fix: check backfill table before Redis so it can override stuck queue…#937

Merged
0xFirekeeper merged 3 commits intomainfrom
feature/backfill-check-before-redis
Mar 24, 2026
Merged

fix: check backfill table before Redis so it can override stuck queue…#937
0xFirekeeper merged 3 commits intomainfrom
feature/backfill-check-before-redis

Conversation

@eabdelmoneim
Copy link
Contributor

@eabdelmoneim eabdelmoneim commented Mar 24, 2026

…d transactions

Previously the backfill lookup only ran when a transaction was missing from Redis. Orphaned "queued" transactions that still exist in Redis were unreachable by backfill. Moving the check first lets backfill entries act as intentional overrides for stuck queue IDs.

Changes

How this PR will be tested

  • Open the dashboard and click X. Result: A modal should appear.
  • Call the /foo/bar API. Result: Returns 200 with "baz" in the response body.

Output

(Example: Screenshot/GIF for UI changes, cURL output for API changes)


PR-Codex overview

This PR enhances the transaction retrieval logic by prioritizing backfill entries for transactions that may not have received webhooks, particularly for AMEX. It simplifies the handling of transaction statuses and reduces redundancy in the code.

Detailed summary

  • Removed redundant comments and code related to AMEX webhook handling.
  • Prioritized backfill entries when fetching transaction logs.
  • Simplified logic for checking transaction status from the backfill table and Redis.
  • Ensured that the backfill entry is authoritative if it exists.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes
    • Improved transaction lookup reliability by prioritizing backfill records for hash resolution and status responses when backfill fallback is enabled.
    • Skips secondary lookups when a backfill record exists, and ensures status endpoints return backfill-based responses immediately.
    • Ensures consistent behavior across both path and query status endpoints.

eabdelmoneim and others added 2 commits March 24, 2026 12:41
…d transactions

Previously the backfill lookup only ran when a transaction was missing
from Redis. Orphaned "queued" transactions that still exist in Redis
were unreachable by backfill. Moving the check first lets backfill
entries act as intentional overrides for stuck queue IDs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same change as status endpoint — backfill entries should take priority
over stale Redis data for consistency across all endpoints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6a609634-6b2a-42e7-953d-7d2893021304

📥 Commits

Reviewing files that changed from the base of the PR and between fc367a5 and be510be.

📒 Files selected for processing (1)
  • src/server/routes/transaction/blockchain/get-logs.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/server/routes/transaction/blockchain/get-logs.ts

Walkthrough

When ENABLE_TX_BACKFILL_FALLBACK is enabled, both transaction route handlers now perform a backfill-first lookup: they call TransactionDB.getBackfill(queueId) before falling back to TransactionDB.get(queueId), returning early on valid mined backfill records.

Changes

Cohort / File(s) Summary
Backfill-First Transaction Lookup
src/server/routes/transaction/blockchain/get-logs.ts, src/server/routes/transaction/status.ts
Reordered transaction resolution to prioritize TransactionDB.getBackfill(queueId) when ENABLE_TX_BACKFILL_FALLBACK is enabled. get-logs.ts now assigns hash only from mined+hex-valid backfill and skips the prior Redis primary lookup when a backfill exists; status.ts returns a backfill response immediately if found, otherwise falls back to TransactionDB.get(queueId) and preserves existing error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant Route as Route Handler
    participant Backfill as TransactionDB.getBackfill
    participant Primary as TransactionDB.get
    participant Redis as Redis (optional)

    Client->>Route: request (queueId)
    Route->>Backfill: getBackfill(queueId)
    alt backfill exists && status == "mined" && valid hash
        Backfill-->>Route: backfill record (mined, hash)
        Route-->>Client: return backfill response
    else no usable backfill
        Route->>Primary: get(queueId)
        alt primary has data
            Primary-->>Route: transaction record (may include hash)
            Route-->>Redis: (existing primary/redis lookup flow) 
            Route-->>Client: return primary response
        else not found
            Primary-->>Route: not found
            Route-->>Client: return TRANSACTION_NOT_FOUND error
        end
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description covers the problem and solution but relies on boilerplate sections that lack specific implementation details for testing and output. Replace placeholder test cases with actual API endpoints being modified (get-logs, status) and provide concrete expected behavior or example outputs for validation.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately identifies the main change: prioritizing backfill table lookup before Redis cache for transaction retrieval.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/backfill-check-before-redis

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/server/routes/transaction/blockchain/get-logs.ts`:
- Around line 161-173: The current logic falls back to
TransactionDB.get(queueId) whenever hash is falsy, which still allows fallback
when a backfill entry exists but is non-mined/errored; change the fallback to
only call TransactionDB.get when there is no backfill entry at all.
Specifically, after calling TransactionDB.getBackfill(queueId)
(env.ENABLE_TX_BACKFILL_FALLBACK and TransactionDB.getBackfill), treat the
presence of a backfill (even if non-mined) as authoritative and only run the
TransactionDB.get(queueId) path when backfill is null/undefined; keep the
existing mined-status check for backfill (backfill?.status === "mined") that
sets hash.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 28f49474-36f0-4508-abc1-eeee1c3709e1

📥 Commits

Reviewing files that changed from the base of the PR and between ec98297 and fc367a5.

📒 Files selected for processing (2)
  • src/server/routes/transaction/blockchain/get-logs.ts
  • src/server/routes/transaction/status.ts

When a backfill entry exists (even if errored), skip the Redis lookup
entirely. Previously an errored backfill entry would fall through to
Redis, potentially returning stale data for an orphaned transaction.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@0xFirekeeper 0xFirekeeper merged commit 0b2cfe9 into main Mar 24, 2026
8 checks passed
@0xFirekeeper 0xFirekeeper deleted the feature/backfill-check-before-redis branch March 24, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants