liftedinit / liftedinit/talib

Events service retries events save even if duplicate key constraint

Open
#323 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
The events service is attempting to save an event entity multiple times due to the design of receiving the latest 100 events from the backend. This is non-blocking but could be reworked to first check the database for an existing event and throw out any. It would reduce overall application error load and reduce attempted writes to the database.

To Reproduce
Steps to reproduce the behavior:

  1. Run the application locally in debug mode with a clone of prod data
  2. Observe event errors such as the following:
Error occurred while saving event: {"neighborhood":{"id":6,"address":{"bytes":{"0":1,"1":161,"2":2,"3":0,"4":212,"5":249,"6":10,"7":35,"8":179,"9":247,"10":229,"11":197,"12":107,"13":141,"14":184,"15":208,"16":6,"17":158,"18":165,"19":37,"20":221,"21":75,"22":62,"23":142,"24":42,"25":181,"26":61,"27":112,"28":4}},"url":"https://alberto.app/api","name":"Manifest Alpha 2 (Current)","enabled":true,"description":null,"serverName":"AbciModule(many-ledger)","attributes":[0,1,2,4,5,6,8,[9,0,1],11,12,1002],"version":"0.0.0"},"eventId":{"type":"Buffer","data":[31,17,109,0,0,0,1]},"timestamp":"2024-07-16T07:35:49.000Z","method":"ledger.send","type":[6,0],"info":{"from":"mahxav47kqz4fvxv7dtfqln6vqjmoayc4v2zofeqeost3lnist","to":"mafk5xrtl6dmny2uvrrlc5ix2z3ucr7tcefwayzrfh4j25pi7m","symbol":"mqbh742x4s356ddaryrxaowt4wxtlocekzpufodvowrirfrqaaaaa3l","amount":"850000000"},"addresses":["mahxav47kqz4fvxv7dtfqln6vqjmoayc4v2zofeqeost3lnist","mafk5xrtl6dmny2uvrrlc5ix2z3ucr7tcefwayzrfh4j25pi7m","mqbh742x4s356ddaryrxaowt4wxtlocekzpufodvowrirfrqaaaaa3l"]}, QueryFailedError: duplicate key value violates unique constraint "UQ_4ee8fd974a5681971c4eb5bb585"

Expected behavior
Prior to saving, the events retrieved from the network endpoints should be queried to determine pre-existence in the database from previous runs. Save new ones, ignore existing ones.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the events service path that receives the latest 100 events and attempts to save them. Reproduce locally with a clone of production data and inspect the duplicate-key errors. Done means existing events are ignored before saving, new events are persisted, and the repeated constraint errors no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.