Skip to content

Consistency and timing

  1. Your write is checked and applied to the database’s working copy on the server.
  2. It is written to a durable log, and then acknowledged.
  3. It is saved to the file in your Google Drive within about 2 seconds, together with any other writes from those seconds.

An acknowledged write is safe even if the server restarts before step 3: the log is replayed. If Google Drive is unreachable for a while, writes stay in the log and are saved when it’s back.

To wait until a write is in Drive, ask for it:

await clients.insertOne(doc, { writeConcern: { w: 'drive' } });

Reads are answered from the working copy, which includes every acknowledged API write at once (read-your-writes). Before answering, the server checks Drive for edits made in the app, at most every 5 seconds.

{ readConcern: 'local' } skips that check for faster reads that may be a few seconds behind the app (never more than a minute).

Change made… Seen by… When
through the API the API immediately
through the API people in the app within about 15 seconds (see below)
in the app the API within about 5 seconds after the app saves it

An app that has the database open checks Drive every 15 seconds for an hour after an API write. If it was already open before the first API write, it notices that write at its next regular check (up to 2 minutes); Sync now in the app checks at once.

Changes merge field by field: if your code updates status while someone edits company of the same record in the app, both changes are kept. If both change the same field at nearly the same moment, the later change wins.

  • Every single call is atomic. insertMany, updateMany, deleteMany and bulkWrite apply all their changes or none (for example when one document fails validation or breaks a unique field).
  • Calls are applied one at a time per database, so $inc never loses an increment and unique fields hold, for all connection strings created by the same Google account.
  • There are no multi-call transactions. Use bulkWrite to change several documents together, or findOneAndUpdate to read and change one document in a single step.

Connection strings created by different Google accounts (for example teammates on a shared database) each get their own working copy. Their writes merge like edits from two devices, so unique fields and $inc are only guaranteed within each account’s connection strings.

Made by Faeiz Furqan