Why the second write to Acme waits
Birch’s order commits while Acme’s transaction is open. Run COMMIT; in the first shell, then retry BEGIN IMMEDIATE; in the second. It now holds Acme’s write lock. Finish with ROLLBACK; to release it.
| Where orders land | What limits them |
|---|---|
| Two orders in Acme’s file | One write transaction at a time, even for different rows. A busy timeout can let the second writer wait. WAL lets readers continue. |
| Thousands of customer files on one host | Locks are per file. Customers still share CPU, free disk space and disk I/O. |
Measure lock waits on the busiest file and disk latency on the host. Shorten long transactions. If many files saturate one host, spread customers across hosts and route each to its writer. How SQLite handles concurrent transactions.
How to restore, delete or migrate one customer’s database
- Restore. Restore Acme to a new path and inspect its orders. To roll back, account for newer orders, pause Acme’s writes, close its connections and revert to the checked version. Birch stays online. Roll back one customer.
- Delete. Stop Acme’s traffic and jobs, close its connections and remove the live file. Retire replicas separately. Server and bucket backups follow retention, so include them in deletion deadlines. Check backup retention.
- Change the schema. Try a nullable column on a few customer files first. Record the schema version in the same transaction. Keep the app working with both schemas during rollout and when opening an older restore.
When to choose PostgreSQL for concurrent writes
If one file stays busy with short transactions and spare host capacity, PostgreSQL can run writes to different rows concurrently. Updates to the same row can still queue.
A monthly sales total across files needs a reporting copy or a query per file, and those reads can reflect different times. Shared tables simplify frequent cross-customer joins and atomic updates. Compare SQLite and PostgreSQL.
Install
Set up one database per customer and choose which writes must survive disk loss.