escrin / nftrout

A fish NFT breeding game with secret genetics known by nobody.
https://nftrout.com
MIT License
4 stars 0 forks source link

Indexer tasks trample each other #6

Open nhynes opened 6 months ago

nhynes commented 6 months ago

Currently it's possible for stale data coming from the large, slow batch-update task to arrive after data from the fast per-block task and overwrite the committed fresh data. So a trout race in some sense, but not the kind we want.

There are two reasonable fixes:

  1. Each indexer task needs to be pinned to a particular block and the database needs to store the more recent block so that updates are idempotent. This is the more complicated, general solution.
  2. Don't have the batch update task re-index the per-block task's data because it's wasteful anyway. This is a simpler solution that will split the code into additional paths.