Skip to content

Commit 4e0a3ce

Browse files
committed
Remove no-op compaction logic
1 parent 62fbba9 commit 4e0a3ce

File tree

2 files changed

+0
-62
lines changed

2 files changed

+0
-62
lines changed

packages/powersync_core/lib/src/sync/bucket_storage.dart

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ typedef LocalOperationCounters = ({int atLast, int sinceLast});
2020
class BucketStorage {
2121
final SqliteConnection _internalDb;
2222
bool _hasCompletedSync = false;
23-
bool _pendingBucketDeletes = false;
24-
int _compactCounter = compactOperationInterval;
2523

2624
BucketStorage(SqliteConnection db) : _internalDb = db {
2725
_init();
@@ -67,11 +65,8 @@ class BucketStorage {
6765
}
6866

6967
Future<void> saveSyncData(SyncDataBatch batch) async {
70-
var count = 0;
71-
7268
await writeTransaction((tx) async {
7369
for (var b in batch.buckets) {
74-
count += b.data.length;
7570
await _updateBucket2(
7671
tx,
7772
jsonEncode({
@@ -82,7 +77,6 @@ class BucketStorage {
8277
// We get major initial sync performance improvements with IndexedDB by
8378
// not flushing here.
8479
}, flush: false);
85-
_compactCounter += count;
8680
}
8781

8882
Future<void> _updateBucket2(SqliteWriteContext tx, String json) async {
@@ -103,8 +97,6 @@ class BucketStorage {
10397
['delete_bucket', bucket]);
10498
// No need to flush - not directly visible to the user
10599
}, flush: false);
106-
107-
_pendingBucketDeletes = true;
108100
}
109101

110102
Future<bool> hasCompletedSync() async {
@@ -154,8 +146,6 @@ class BucketStorage {
154146
return SyncLocalDatabaseResult(ready: false);
155147
}
156148

157-
await forceCompact();
158-
159149
return SyncLocalDatabaseResult(ready: true);
160150
}
161151

@@ -226,52 +216,6 @@ UPDATE ps_buckets SET count_since_last = 0, count_at_last = ?1->name
226216
}
227217
}
228218

229-
Future<void> forceCompact() async {
230-
_compactCounter = compactOperationInterval;
231-
_pendingBucketDeletes = true;
232-
233-
await autoCompact();
234-
}
235-
236-
Future<void> autoCompact() async {
237-
// This is a no-op since powersync-sqlite-core v0.3.0
238-
239-
// 1. Delete buckets
240-
await _deletePendingBuckets();
241-
242-
// 2. Clear REMOVE operations, only keeping PUT ones
243-
await _clearRemoveOps();
244-
}
245-
246-
Future<void> _deletePendingBuckets() async {
247-
// This is a no-op since powersync-sqlite-core v0.3.0
248-
if (_pendingBucketDeletes) {
249-
// Executed once after start-up, and again when there are pending deletes.
250-
await writeTransaction((tx) async {
251-
await tx.execute(
252-
'INSERT INTO powersync_operations(op, data) VALUES (?, ?)',
253-
['delete_pending_buckets', '']);
254-
// No need to flush - not directly visible to the user
255-
}, flush: false);
256-
_pendingBucketDeletes = false;
257-
}
258-
}
259-
260-
Future<void> _clearRemoveOps() async {
261-
if (_compactCounter < compactOperationInterval) {
262-
return;
263-
}
264-
265-
// This is a no-op since powersync-sqlite-core v0.3.0
266-
await writeTransaction((tx) async {
267-
await tx.execute(
268-
'INSERT INTO powersync_operations(op, data) VALUES (?, ?)',
269-
['clear_remove_ops', '']);
270-
// No need to flush - not directly visible to the user
271-
}, flush: false);
272-
_compactCounter = 0;
273-
}
274-
275219
void setTargetCheckpoint(Checkpoint checkpoint) {
276220
// No-op for now
277221
}

packages/powersync_core/test/bucket_storage_test.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ void main() {
556556
writeCheckpoint: '4',
557557
checksums: [checksum(bucket: 'bucket1', checksum: 7)]));
558558

559-
await bucketStorage.forceCompact();
560-
561559
await syncLocalChecked(Checkpoint(
562560
lastOpId: '4',
563561
writeCheckpoint: '4',
@@ -604,8 +602,6 @@ void main() {
604602
writeCheckpoint: '4',
605603
checksums: [checksum(bucket: 'bucket1', checksum: 2147483642)]));
606604

607-
await bucketStorage.forceCompact();
608-
609605
await syncLocalChecked(Checkpoint(
610606
lastOpId: '4',
611607
writeCheckpoint: '4',
@@ -645,8 +641,6 @@ void main() {
645641
writeCheckpoint: '4',
646642
checksums: [checksum(bucket: 'bucket1', checksum: -3)]));
647643

648-
await bucketStorage.forceCompact();
649-
650644
await syncLocalChecked(Checkpoint(
651645
lastOpId: '4',
652646
writeCheckpoint: '4',

0 commit comments

Comments
 (0)