Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.62k stars 600 forks source link

Will update existing record instead but still fails. #1666

Open CDBridger opened 1 year ago

CDBridger commented 1 year ago

Currently experiencing an error in the backend which means its sending updated records as created, that's on us. My question is, the error it throws implies it will still update the database

[Diagnostic error: [Sync] Server wants client to create record projectMarkers#vbb9k2j6vksl7vgf, but it already exists locally. This may suggest last sync partially executed, and then failed; or it could be a serious bug. Will update existing record instead.]

but then at the end it doesn't updated/create the record to at all and throws

 Failed to execute db update - sqlite error 1555 (UNIQUE constraint failed: projectMarkers.id)

which means A bunch of the records which are created are never added to the database (that came in the same payload)

"react-native": "0.72.3", "@nozbe/watermelondb": "^0.26.0",

CDBridger commented 1 year ago

As a note we have fixed the issue in our backend but I'm still curious to get an answer to this question.

hrahul2605 commented 11 months ago

@CDBridger how did you fix this ?

@radex facing this issue, any idea on why this is happening ?

CDBridger commented 11 months ago

We had a timestamp issue which was causing updated records to be sent, it didn't fix the created entries not being created (but we are no longer hitting this bug because of the aforementioned bug fix).