File tree Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.16.4
2
+
3
+ - Refactor of file locks during a vacuum
4
+
5
+ ## 0.16.3
6
+
7
+ - Added ` KV.defer(promiseToHandle, [errorHandler], [timeoutMs]) ` method to allow
8
+ non-awaited promises to be tracked and settled during ` KV.close() ` .
9
+ - ` errorHandler ` (optional): A function to handle errors that occur during
10
+ promise resolution/rejection. If not provided, errors will silently ignored.
11
+ - ` timeoutMs ` (optional): A timeout (in milliseconds) for promise resolution.
12
+ If the promise doesn't settle within this time during ` KV.close() ` , a
13
+ warning will be logged. Defaults to 5000ms.
14
+ - Fix cli tool not being able to open any database after a failed open
15
+ - Code refactors
16
+
1
17
## 0.16.3
2
18
3
19
- Added ` KV.defer(promiseToHandle, [errorHandler], [timeoutMs]) ` method to allow
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @cross/kv" ,
3
- "version" : " 0.16.3 " ,
3
+ "version" : " 0.16.4 " ,
4
4
"exports" : {
5
5
"." : " ./mod.ts" ,
6
6
"./cli" : " ./src/cli/mod.ts"
7
7
},
8
+ "lint" : {
9
+ "rules" : {
10
+ "exclude" : [
11
+ " no-node-globals"
12
+ ]
13
+ }
14
+ },
8
15
"imports" : {
9
16
"@cross/fs" : " jsr:@cross/fs@^0.1.11" ,
10
17
"@cross/runtime" : " jsr:@cross/runtime@^1.0.0" ,
11
18
"@cross/test" : " jsr:@cross/test@^0.0.9" ,
12
- "@cross/utils" : " jsr:@cross/utils@^0.13 .0" ,
13
- "@std/assert" : " jsr:@std/assert@^0.226.0 " ,
14
- "@std/path" : " jsr:@std/path@^0.225.1 " ,
19
+ "@cross/utils" : " jsr:@cross/utils@^0.14 .0" ,
20
+ "@std/assert" : " jsr:@std/assert@^1.0.4 " ,
21
+ "@std/path" : " jsr:@std/path@^1.0.4 " ,
15
22
"cbor-x" : " npm:cbor-x@^1.5.9" ,
16
23
"ohash" : " npm:ohash@^1.1.3"
17
24
},
Original file line number Diff line number Diff line change @@ -76,6 +76,8 @@ async function stats(
76
76
ledgerSetCount ++ ;
77
77
} else if ( entry . operation === KVOperation . DELETE ) {
78
78
ledgerDeleteCount ++ ;
79
+ } else {
80
+ ledgerInvalidCount ++ ;
79
81
}
80
82
}
81
83
} catch ( _e ) {
@@ -89,7 +91,6 @@ async function stats(
89
91
console . log ( Colors . dim ( ` Delete Ops: ` ) , ledgerDeleteCount ) ;
90
92
if ( ledgerInvalidCount ) {
91
93
console . log ( Colors . red ( ` Invalid Ops: ` ) , ledgerInvalidCount ) ;
92
- console . error ( " Counting aborted due to invalid operations" ) ;
93
94
}
94
95
95
96
console . log ( "" ) ;
Original file line number Diff line number Diff line change @@ -461,6 +461,10 @@ export class KVLedger {
461
461
) ;
462
462
await tempLedger . open ( true ) ;
463
463
464
+ // Lock the temporary ledger to prevent multiple vacuums against the same tempfile
465
+ // - Will be unlocked in the finally clause
466
+ await tempLedger . lock ( ) ;
467
+
464
468
// 5. Append valid transactions to the new file.
465
469
for ( const validTransaction of validTransactions ) {
466
470
const transaction = await this . rawGetTransaction (
@@ -478,7 +482,6 @@ export class KVLedger {
478
482
this . prefetch . clear ( ) ;
479
483
480
484
// 7. Replace Original File
481
- // - The lock flag is now set independently, no need to unlock from this point on
482
485
await unlink ( this . dataPath ) ;
483
486
await rename ( tempFilePath , this . dataPath ) ;
484
487
ledgerIsReplaced = true ;
You can’t perform that action at this time.
0 commit comments