News for hackers. Stuff that matters.
Re:Cloud Firestore: A New Document Database for Apps by judah on Tuesday October 03, 2017 @01:10PM (#15393997)
What's your story on ACID, particularly on transactions?

Transactions: If I want to insert 2 documents, but zero if either fails, what does that look like with Firestore?

And if I store a document and run a query milliseconds later, will the query include document I just stored? Or are queries eventually consistent?

Re:Cloud Firestore: A New Document Database for Apps by habosa on Tuesday October 03, 2017 @01:15PM (#15394050)
Cloud Firestore has support for transactions: https://firebase.google.com/docs/firestore/manage-data/updat...

So yes, if any of the operations in the transaction fails (and cannot be retried) the whole transaction will fail. It's atomic as you'd expect. If you've ever used transactions in Firebase Realtime Database you'll be happy to know that the transactions in Cloud Firestore are much easier to use since they don't require selecting a common data parent.

Queries are always strongly consistent. If you do a write-read sequence you'll see the value of the latest write.

Re:Cloud Firestore: A New Document Database for Apps by ibdknox on Tuesday October 03, 2017 @01:47PM (#15394389)
How do you deal with consistency in the offline case? E.g. If I make a bunch of edits while disconnected, and others have made edits while connected, how are the conflicts resolved?
Re:Cloud Firestore: A New Document Database for Apps by mikelehen on Tuesday October 03, 2017 @02:02PM (#15394536)
This works similar to the Realtime Database in that it's last-write wins (where in the offline case, "last" is the last person to come back online and send their write to the backend). This model is very easy for developers to understand and directly solves many use cases, especially since we allow very granular writes which reduces the risk of conflicts. But for more complex use cases, you can get clever and implement things like OT conflict resolution as a layer on top of last-write wins, e.g. similar to how we implemented collaborative editing with www.firepad.io on the realtime database.

PS: Hi Chris! :-)

Re:Cloud Firestore: A New Document Database for Apps by ibdknox on Tuesday October 03, 2017 @02:39PM (#15394860)
Hey Michael! Congrats on the launch :)

Providing a one-size-fits-all solution here is probably impossible, but it seems like it would be nice to provide some mechanism to be notified that you're making edits based on stale information. If such a mechanism existed, it would be easy to add a bunch of canned merge strategies. In doing so you can probably teach people a little bit about the pitfalls they're likely to run into (these sorts of bugs are insanely difficult to track down), while not really making them do much work.

The approach we've taken in Eve is that we can't solve all these problems for you, but we can at least let you know that things can go sideways and prompt you to make a deliberate decision about what should happen. It's amazing how helpful that ends up being.

Re:Cloud Firestore: A New Document Database for Apps by mikelehen on Tuesday October 03, 2017 @04:35PM (#15395927)
Thanks for the feedback. I think you're right and we're interested in exploring what we can do to help people more in the future. One of the really nice things about Cloud Firestore is that documents are versioned with timestamps in such a way that we could definitely detect and expose conflicts and let you decide how to deal with them... It's mostly a matter of identifying the common use cases and then figuring out the right API to make them possible without going too far into the deep end of conflict resolution.
Re:Cloud Firestore: A New Document Database for Apps by lozenge on Tuesday October 03, 2017 @03:32PM (#15395358)
It looks to me like Firestore's API doesn't include a "default" way to upload user edits to documents. Conflict detection is possible using the transactions - https://cloud.google.com/firestore/docs/manage-data/update-d... - you can do something like HTTP's PUT If-Unmodified-Since (or PUT If-Match).
Re:Cloud Firestore: A New Document Database for Apps by mikelehen on Tuesday October 03, 2017 @04:27PM (#15395868)
Good point. read-modify-write transactions are a good way to detect conflicts and get a chance to handle them, but they're unfortunately limited to while the client is online. If the client is offline, the transaction will fail so they're not useful for general conflict resolution. This was an intentional decision because there's not a straightforward way to preserve the intent of the transaction across app restarts. But there may be options for adding some sort of conflict resolution strategy in the future that leverages the same underlying primitives that transactions use today.
Re:Cloud Firestore: A New Document Database for Apps by euyyn on Tuesday October 03, 2017 @04:11PM (#15395721)
> OT conflict resolution as a layer on top of last-write wins

Can you link to somewhere where this layering is explained?

The www.firepad.io site has documentation on how to use the editor, but I'm interested in how "OT on top of last-write wins" is achieved.