fix: reject unsafe version cleanup windows

This commit is contained in:
Gatefixer
2026-08-06 04:00:56 +00:00
parent c7ea91f3ea
commit d8c5695b7b
9 changed files with 163 additions and 22 deletions
+3
View File
@@ -587,6 +587,9 @@ Modeled after ``VACUUM`` in PostgreSQL.
you have added or modified 100,000 or more records or run more than 20 data
modification operations.
Cleanup retention must exceed the longest expected write. Retention shorter
than 10 minutes requires `deleteUnverified: true` and exclusive write access.
#### Parameters
* **options?**: `Partial`<[`OptimizeOptions`](../interfaces/OptimizeOptions.md)>
+6 -3
View File
@@ -16,7 +16,10 @@ cleanupOlderThan: Date;
If set then all versions older than the given date
be removed. The current version will never be removed.
The default is 7 days
The default is 7 days. The resulting retention period must be longer than
the longest expected write. Values shorter than 10 minutes require
`deleteUnverified: true` and are only safe when no other process can write
to the dataset.
#### Example
@@ -26,8 +29,8 @@ const olderThan = new Date();
olderThan.setDate(olderThan.getDate() - 1));
tbl.optimize({cleanupOlderThan: olderThan});
// Delete all versions except the current version
tbl.optimize({cleanupOlderThan: new Date()});
// With exclusive access, delete all versions except the current version
tbl.optimize({cleanupOlderThan: new Date(), deleteUnverified: true});
```
***