Skip to content

Commit

Permalink
workaround missing waitForFirstSync()
Browse files Browse the repository at this point in the history
  • Loading branch information
nurturenature committed Jul 28, 2024
1 parent 1e97081 commit 9af235c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
18 changes: 17 additions & 1 deletion doc/logbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@

Add partitioning and process kill nemeses to flush out more errors and observe behaviors.


Workaround `waitForFirstSync()` by sleeping for 1s
- slightly changes behavior of kill nemesis
- minimum of 1s interval between kills vs a possibly, random, interval of 0
- slightly changes startup behavior
- 1s delay avoids the sometimes, random, initial transactions before/during setup


Possible Issues
- frequent, extraneous?, duplicate `SyncStatus` stream messages
```log
[2:13:41.301] [powersync_endpoint] FINEST: statusStream: SyncStatus<connected: true connecting: false downloading: true uploading: false lastSyncedAt: 2024-07-28 02:13:40.138093, hasSynced: true, error: null>
[2:13:41.301] [powersync_endpoint] FINEST: statusStream: SyncStatus<connected: true connecting: false downloading: true uploading: false lastSyncedAt: 2024-07-28 02:13:40.138093, hasSynced: true, error: null>
```

---

### Known Errors In New CrudTransactionConnector

- PostgreSQL could not serialize access due to concurrent update
- Max retries, 10, exceeded

TODO: Implement exponential backoff?
TODO: Implement a try hard, try harder, 'reverse' exponential backoff?
- fair and polite

----

Expand Down
6 changes: 5 additions & 1 deletion jepsen/src/powersync/powersync.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[db :as db]
[control :as c]]
[jepsen.control
[util :as cu]]))
[util :as cu]]
[jepsen.util :as util]))

(def install-dir
"Directory to install into."
Expand Down Expand Up @@ -92,6 +93,9 @@
:logfile log-file
:pidfile pid-file}
bin-path))
; TODO: not possible to waitForFirstSync() in powersync_endpoint, so sleep here
(info "Sleeping for 1 second to mimic waitForFirstSync()")
(util/sleep 1000)
:started)))

(kill!
Expand Down
7 changes: 5 additions & 2 deletions powersync_endpoint/lib/db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ Future<void> initDb() async {
await db.connect(connector: connector);
log.info('db connected, connector: $connector, status: ${db.currentStatus}');

await db.waitForFirstSync();
log.info('db first sync completed, status: ${db.currentStatus}');
// TODO: disappeared from API?
// https://github.com/powersync-ja/powersync.dart/issues/131
log.warning("not waitForFirstSync()'ing");
// await db.waitForFirstSync();
// log.info('db first sync completed, status: ${db.currentStatus}');

// log PowerSync status changes
// monitor for upload error messages, check if they're ignorable
Expand Down

0 comments on commit 9af235c

Please sign in to comment.