Replication
Resetting
During development we all do strange things (unsafely changing schemas, removing files, etc.). If the replica ever gets wedged (stops replicating, acts strange) you can wipe it and start over.
- If you copied your setup from
hello-zeroorhello-zero-solid, you can also runnpm run dev:clean - Otherwise you can run
rm /tmp/my-zero-replica.db*(see your.envfile for the replica file location) to clear the contents of the replica.
It is always safe to wipe the replica. Wiping will have no impact on your upstream database. Downstream zero-clients will get re-synced when they connect.
Inspecting
For data to be synced to the client it must first be replicated to zero-cache. You can check the contents of zero-cache via:
$ npx zero-sqlite3 /tmp/my-zero-replica.db
This will drop you into a sqlite3 shell with which you can use to explore the contents of the replica.
sqlite> .tables
_zero.changeLog emoji viewState
_zero.replicationConfig issue zero.permissions
_zero.replicationState issueLabel zero.schemaVersions
_zero.runtimeEvents label zero_0.clients
_zero.versionHistory user
comment userPref
sqlite> .mode qbox
sqlite> SELECT * FROM label;
┌─────────────────────────┬──────────────────────────┬────────────┐
│ id │ name │ _0_version │
├─────────────────────────┼──────────────────────────┼────────────┤
│ 'ic_g-DZTYDApZR_v7Cdcy' │ 'bug' │ '4ehreg' │
...
Miscellaneous
If you see FATAL: sorry, too many clients already in logs, it’s because you have two zero-cache instances running against dev. One is probably in a background tab somewhere. In production, zero-cache can run horizontally scaled but on dev it doesn’t run in the config that allows that.