How does the Firestore web SDK handle write + mediate collisions with offline clients?
[REQUIRED] Describe your environment
- Operating System version: n/a
- Browser version: n/a
- Firebase SDK version: 8.1.1
- Firebase Product: firestore (auth, database, storage, etc)
If I have the same user, and they're using two devices, and made a change on both, what happens when they have a collision.
Say you set a value on deviceA to 101 and then on deviceB to 102.
Is there any ordering or is it just the last writer wins?
I'm working on my own offline caching for Firestore so want to duplicate the exact same functionality that the current SDK has.
My cache has support for secondary indexes so it's already much faster. It's open source if you guys wanted to link to it.
Just need to figure out how you do offline writes and it will be feature identical for the most part.
@burtonator Firestore uses "last write wins" for its conflict resolution - but the winning write is the last write that is sent to the backend, not necessarily the last write that occurred on an (offline) device. Offline devices replay their edits when they gain back connectivity and can therefore replace edits that were made by other devices.
Please take a look here for some mitigation strategies: https://stackoverflow.com/questions/51083190/firestore-what-happens-when-an-offline-device-goes-online