sliftutils 1.9.7 → 1.9.8
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/index.d.ts
CHANGED
|
@@ -1182,7 +1182,7 @@ declare module "sliftutils/storage/BulkDatabase2/BulkDatabaseBase" {
|
|
|
1182
1182
|
export type BulkDatabase2Config = {
|
|
1183
1183
|
maxTriggerThrottleMs?: number;
|
|
1184
1184
|
};
|
|
1185
|
-
export type MergeSkipReason = "mergeInFlight" | "tabLockHeld" | "fileLockHeld" | "nothingToMerge";
|
|
1185
|
+
export type MergeSkipReason = "mergeInFlight" | "tabLockHeld" | "fileLockHeld" | "fileLockUnwritable" | "nothingToMerge";
|
|
1186
1186
|
export type MergeAttemptResult = {
|
|
1187
1187
|
merged: boolean;
|
|
1188
1188
|
skipReason?: MergeSkipReason;
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ export type StorageFactory = (path: string) => Promise<FileStorage>;
|
|
|
28
28
|
export type BulkDatabase2Config = {
|
|
29
29
|
maxTriggerThrottleMs?: number;
|
|
30
30
|
};
|
|
31
|
-
export type MergeSkipReason = "mergeInFlight" | "tabLockHeld" | "fileLockHeld" | "nothingToMerge";
|
|
31
|
+
export type MergeSkipReason = "mergeInFlight" | "tabLockHeld" | "fileLockHeld" | "fileLockUnwritable" | "nothingToMerge";
|
|
32
32
|
export type MergeAttemptResult = {
|
|
33
33
|
merged: boolean;
|
|
34
34
|
skipReason?: MergeSkipReason;
|
|
@@ -111,6 +111,7 @@ export type MergeSkipReason =
|
|
|
111
111
|
| "tabLockHeld"
|
|
112
112
|
// Another process holds the cross-process .merge-lock file (or won the settle race for it).
|
|
113
113
|
| "fileLockHeld"
|
|
114
|
+
| "fileLockUnwritable"
|
|
114
115
|
// compact() only: the collection has no files on disk.
|
|
115
116
|
| "nothingToMerge";
|
|
116
117
|
|
|
@@ -689,7 +690,7 @@ export class BulkDatabaseBase<T extends { key: string }> {
|
|
|
689
690
|
try {
|
|
690
691
|
await this.tryMergeThrottled();
|
|
691
692
|
} catch (e) {
|
|
692
|
-
console.warn(`${this.name}: background merge failed
|
|
693
|
+
console.warn(`${this.name}: background merge failed:`, (e as Error).stack ?? e);
|
|
693
694
|
}
|
|
694
695
|
}
|
|
695
696
|
|
|
@@ -714,7 +715,14 @@ export class BulkDatabaseBase<T extends { key: string }> {
|
|
|
714
715
|
if (this.mergeInFlight) return await this.mergeSkip("mergeInFlight");
|
|
715
716
|
if (!tryAcquireMergeLock(this.name, writerId)) return await this.mergeSkip("tabLockHeld");
|
|
716
717
|
const storage = await this.storage();
|
|
717
|
-
|
|
718
|
+
let haveFileLock: boolean;
|
|
719
|
+
try {
|
|
720
|
+
haveFileLock = await tryAcquireMergeFileLock(storage, writerId);
|
|
721
|
+
} catch (e) {
|
|
722
|
+
releaseMergeLock(this.name, writerId);
|
|
723
|
+
console.warn(`${blue(this.name)} ${magenta("merge")} skipped: fileLockUnwritable, writer ${writerId} could not write .merge-lock:`, (e as Error).stack ?? e);
|
|
724
|
+
return { merged: false, skipReason: "fileLockUnwritable" };
|
|
725
|
+
}
|
|
718
726
|
if (!haveFileLock) {
|
|
719
727
|
releaseMergeLock(this.name, writerId);
|
|
720
728
|
return await this.mergeSkip("fileLockHeld");
|