dataply 0.0.26-alpha.3 → 0.0.26-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +53 -39
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -447,11 +447,7 @@ var MVCCTransaction = class {
|
|
|
447
447
|
*/
|
|
448
448
|
rollback() {
|
|
449
449
|
const { created, updated, deleted } = this.getResultEntries();
|
|
450
|
-
this.
|
|
451
|
-
this.deleteBuffer.clear();
|
|
452
|
-
this.createdKeys.clear();
|
|
453
|
-
this.deletedValues.clear();
|
|
454
|
-
this.originallyExisted.clear();
|
|
450
|
+
this._cleanupAll();
|
|
455
451
|
this.committed = true;
|
|
456
452
|
if (this.root !== this) {
|
|
457
453
|
this.root.activeTransactions.delete(this);
|
|
@@ -487,6 +483,19 @@ var MVCCTransaction = class {
|
|
|
487
483
|
}
|
|
488
484
|
return Array.from(conflicts);
|
|
489
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* Cleans up all buffers and history.
|
|
488
|
+
* This method is called by the commit method.
|
|
489
|
+
*/
|
|
490
|
+
_cleanupAll() {
|
|
491
|
+
this.writeBuffer.clear();
|
|
492
|
+
this.deleteBuffer.clear();
|
|
493
|
+
this.createdKeys.clear();
|
|
494
|
+
this.deletedValues.clear();
|
|
495
|
+
this.originallyExisted.clear();
|
|
496
|
+
this.keyVersions.clear();
|
|
497
|
+
this.bufferHistory.clear();
|
|
498
|
+
}
|
|
490
499
|
/**
|
|
491
500
|
* Cleans up both deletedCache and versionIndex based on minActiveVersion.
|
|
492
501
|
* Root transactions call this after commit to reclaim memory.
|
|
@@ -678,6 +687,7 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
678
687
|
if (this.parent) {
|
|
679
688
|
const failure = this.parent._merge(this);
|
|
680
689
|
if (failure) {
|
|
690
|
+
this.rollback();
|
|
681
691
|
return {
|
|
682
692
|
label,
|
|
683
693
|
success: false,
|
|
@@ -688,11 +698,13 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
688
698
|
deleted
|
|
689
699
|
};
|
|
690
700
|
}
|
|
701
|
+
this._cleanupAll();
|
|
691
702
|
this.committed = true;
|
|
692
703
|
} else {
|
|
693
704
|
if (this.writeBuffer.size > 0 || this.deleteBuffer.size > 0) {
|
|
694
705
|
const failure = this._merge(this);
|
|
695
706
|
if (failure) {
|
|
707
|
+
this.rollback();
|
|
696
708
|
return {
|
|
697
709
|
label,
|
|
698
710
|
success: false,
|
|
@@ -703,13 +715,7 @@ var SyncMVCCTransaction = class _SyncMVCCTransaction extends MVCCTransaction {
|
|
|
703
715
|
deleted: []
|
|
704
716
|
};
|
|
705
717
|
}
|
|
706
|
-
this.
|
|
707
|
-
this.deleteBuffer.clear();
|
|
708
|
-
this.createdKeys.clear();
|
|
709
|
-
this.deletedValues.clear();
|
|
710
|
-
this.originallyExisted.clear();
|
|
711
|
-
this.keyVersions.clear();
|
|
712
|
-
this.bufferHistory.clear();
|
|
718
|
+
this._cleanupAll();
|
|
713
719
|
this.localVersion = 0;
|
|
714
720
|
this.snapshotVersion = this.version;
|
|
715
721
|
}
|
|
@@ -1343,6 +1349,7 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
1343
1349
|
if (this.parent) {
|
|
1344
1350
|
const failure = await this.parent._merge(this);
|
|
1345
1351
|
if (failure) {
|
|
1352
|
+
this.rollback();
|
|
1346
1353
|
return {
|
|
1347
1354
|
label,
|
|
1348
1355
|
success: false,
|
|
@@ -1353,11 +1360,13 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
1353
1360
|
deleted
|
|
1354
1361
|
};
|
|
1355
1362
|
}
|
|
1363
|
+
this._cleanupAll();
|
|
1356
1364
|
this.committed = true;
|
|
1357
1365
|
} else {
|
|
1358
1366
|
if (this.writeBuffer.size > 0 || this.deleteBuffer.size > 0) {
|
|
1359
1367
|
const failure = await this._merge(this);
|
|
1360
1368
|
if (failure) {
|
|
1369
|
+
this.rollback();
|
|
1361
1370
|
return {
|
|
1362
1371
|
label,
|
|
1363
1372
|
success: false,
|
|
@@ -1368,13 +1377,7 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
1368
1377
|
deleted: []
|
|
1369
1378
|
};
|
|
1370
1379
|
}
|
|
1371
|
-
this.
|
|
1372
|
-
this.deleteBuffer.clear();
|
|
1373
|
-
this.createdKeys.clear();
|
|
1374
|
-
this.deletedValues.clear();
|
|
1375
|
-
this.originallyExisted.clear();
|
|
1376
|
-
this.keyVersions.clear();
|
|
1377
|
-
this.bufferHistory.clear();
|
|
1380
|
+
this._cleanupAll();
|
|
1378
1381
|
this.localVersion = 0;
|
|
1379
1382
|
this.snapshotVersion = this.version;
|
|
1380
1383
|
}
|
|
@@ -2929,8 +2932,12 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2929
2932
|
result = this.rootTx.commit(label);
|
|
2930
2933
|
if (result.success) {
|
|
2931
2934
|
this.rootTx.rootId = this.rootId;
|
|
2935
|
+
} else {
|
|
2936
|
+
this.mvcc.rollback();
|
|
2932
2937
|
}
|
|
2933
2938
|
}
|
|
2939
|
+
} else {
|
|
2940
|
+
this.mvcc.rollback();
|
|
2934
2941
|
}
|
|
2935
2942
|
return result;
|
|
2936
2943
|
}
|
|
@@ -4131,8 +4138,12 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
4131
4138
|
result = await this.rootTx.commit(label);
|
|
4132
4139
|
if (result.success) {
|
|
4133
4140
|
this.rootTx.rootId = this.rootId;
|
|
4141
|
+
} else {
|
|
4142
|
+
this.mvcc.rollback();
|
|
4134
4143
|
}
|
|
4135
4144
|
}
|
|
4145
|
+
} else {
|
|
4146
|
+
this.mvcc.rollback();
|
|
4136
4147
|
}
|
|
4137
4148
|
return result;
|
|
4138
4149
|
}
|
|
@@ -5403,11 +5414,7 @@ var MVCCTransaction2 = class {
|
|
|
5403
5414
|
*/
|
|
5404
5415
|
rollback() {
|
|
5405
5416
|
const { created, updated, deleted } = this.getResultEntries();
|
|
5406
|
-
this.
|
|
5407
|
-
this.deleteBuffer.clear();
|
|
5408
|
-
this.createdKeys.clear();
|
|
5409
|
-
this.deletedValues.clear();
|
|
5410
|
-
this.originallyExisted.clear();
|
|
5417
|
+
this._cleanupAll();
|
|
5411
5418
|
this.committed = true;
|
|
5412
5419
|
if (this.root !== this) {
|
|
5413
5420
|
this.root.activeTransactions.delete(this);
|
|
@@ -5443,6 +5450,19 @@ var MVCCTransaction2 = class {
|
|
|
5443
5450
|
}
|
|
5444
5451
|
return Array.from(conflicts);
|
|
5445
5452
|
}
|
|
5453
|
+
/**
|
|
5454
|
+
* Cleans up all buffers and history.
|
|
5455
|
+
* This method is called by the commit method.
|
|
5456
|
+
*/
|
|
5457
|
+
_cleanupAll() {
|
|
5458
|
+
this.writeBuffer.clear();
|
|
5459
|
+
this.deleteBuffer.clear();
|
|
5460
|
+
this.createdKeys.clear();
|
|
5461
|
+
this.deletedValues.clear();
|
|
5462
|
+
this.originallyExisted.clear();
|
|
5463
|
+
this.keyVersions.clear();
|
|
5464
|
+
this.bufferHistory.clear();
|
|
5465
|
+
}
|
|
5446
5466
|
/**
|
|
5447
5467
|
* Cleans up both deletedCache and versionIndex based on minActiveVersion.
|
|
5448
5468
|
* Root transactions call this after commit to reclaim memory.
|
|
@@ -5634,6 +5654,7 @@ var SyncMVCCTransaction2 = class _SyncMVCCTransaction2 extends MVCCTransaction2
|
|
|
5634
5654
|
if (this.parent) {
|
|
5635
5655
|
const failure = this.parent._merge(this);
|
|
5636
5656
|
if (failure) {
|
|
5657
|
+
this.rollback();
|
|
5637
5658
|
return {
|
|
5638
5659
|
label,
|
|
5639
5660
|
success: false,
|
|
@@ -5644,11 +5665,13 @@ var SyncMVCCTransaction2 = class _SyncMVCCTransaction2 extends MVCCTransaction2
|
|
|
5644
5665
|
deleted
|
|
5645
5666
|
};
|
|
5646
5667
|
}
|
|
5668
|
+
this._cleanupAll();
|
|
5647
5669
|
this.committed = true;
|
|
5648
5670
|
} else {
|
|
5649
5671
|
if (this.writeBuffer.size > 0 || this.deleteBuffer.size > 0) {
|
|
5650
5672
|
const failure = this._merge(this);
|
|
5651
5673
|
if (failure) {
|
|
5674
|
+
this.rollback();
|
|
5652
5675
|
return {
|
|
5653
5676
|
label,
|
|
5654
5677
|
success: false,
|
|
@@ -5659,13 +5682,7 @@ var SyncMVCCTransaction2 = class _SyncMVCCTransaction2 extends MVCCTransaction2
|
|
|
5659
5682
|
deleted: []
|
|
5660
5683
|
};
|
|
5661
5684
|
}
|
|
5662
|
-
this.
|
|
5663
|
-
this.deleteBuffer.clear();
|
|
5664
|
-
this.createdKeys.clear();
|
|
5665
|
-
this.deletedValues.clear();
|
|
5666
|
-
this.originallyExisted.clear();
|
|
5667
|
-
this.keyVersions.clear();
|
|
5668
|
-
this.bufferHistory.clear();
|
|
5685
|
+
this._cleanupAll();
|
|
5669
5686
|
this.localVersion = 0;
|
|
5670
5687
|
this.snapshotVersion = this.version;
|
|
5671
5688
|
}
|
|
@@ -6299,6 +6316,7 @@ var AsyncMVCCTransaction2 = class _AsyncMVCCTransaction2 extends MVCCTransaction
|
|
|
6299
6316
|
if (this.parent) {
|
|
6300
6317
|
const failure = await this.parent._merge(this);
|
|
6301
6318
|
if (failure) {
|
|
6319
|
+
this.rollback();
|
|
6302
6320
|
return {
|
|
6303
6321
|
label,
|
|
6304
6322
|
success: false,
|
|
@@ -6309,11 +6327,13 @@ var AsyncMVCCTransaction2 = class _AsyncMVCCTransaction2 extends MVCCTransaction
|
|
|
6309
6327
|
deleted
|
|
6310
6328
|
};
|
|
6311
6329
|
}
|
|
6330
|
+
this._cleanupAll();
|
|
6312
6331
|
this.committed = true;
|
|
6313
6332
|
} else {
|
|
6314
6333
|
if (this.writeBuffer.size > 0 || this.deleteBuffer.size > 0) {
|
|
6315
6334
|
const failure = await this._merge(this);
|
|
6316
6335
|
if (failure) {
|
|
6336
|
+
this.rollback();
|
|
6317
6337
|
return {
|
|
6318
6338
|
label,
|
|
6319
6339
|
success: false,
|
|
@@ -6324,13 +6344,7 @@ var AsyncMVCCTransaction2 = class _AsyncMVCCTransaction2 extends MVCCTransaction
|
|
|
6324
6344
|
deleted: []
|
|
6325
6345
|
};
|
|
6326
6346
|
}
|
|
6327
|
-
this.
|
|
6328
|
-
this.deleteBuffer.clear();
|
|
6329
|
-
this.createdKeys.clear();
|
|
6330
|
-
this.deletedValues.clear();
|
|
6331
|
-
this.originallyExisted.clear();
|
|
6332
|
-
this.keyVersions.clear();
|
|
6333
|
-
this.bufferHistory.clear();
|
|
6347
|
+
this._cleanupAll();
|
|
6334
6348
|
this.localVersion = 0;
|
|
6335
6349
|
this.snapshotVersion = this.version;
|
|
6336
6350
|
}
|
|
@@ -9984,10 +9998,10 @@ var Transaction = class {
|
|
|
9984
9998
|
if (shouldTriggerCheckpoint) {
|
|
9985
9999
|
await this.pfs.checkpoint();
|
|
9986
10000
|
}
|
|
10001
|
+
} finally {
|
|
9987
10002
|
this.dirtyPages.clear();
|
|
9988
10003
|
this.undoPages.clear();
|
|
9989
10004
|
this.releaseAllLocks();
|
|
9990
|
-
} finally {
|
|
9991
10005
|
if (this._writeLockRelease) {
|
|
9992
10006
|
this._writeLockRelease();
|
|
9993
10007
|
this._writeLockRelease = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dataply",
|
|
3
|
-
"version": "0.0.26-alpha.
|
|
3
|
+
"version": "0.0.26-alpha.4",
|
|
4
4
|
"description": "A lightweight storage engine for Node.js with support for MVCC, WAL.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "izure <admin@izure.org>",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"cache-entanglement": "^1.7.1",
|
|
49
49
|
"hookall": "^2.2.0",
|
|
50
|
-
"mvcc-api": "^1.3.
|
|
50
|
+
"mvcc-api": "^1.3.6",
|
|
51
51
|
"ryoiki": "^1.2.0",
|
|
52
|
-
"serializable-bptree": "^8.4.
|
|
52
|
+
"serializable-bptree": "^8.4.1"
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|