querysub 0.681.0 → 0.683.0
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/package.json
CHANGED
|
@@ -209,7 +209,7 @@ export function createArchiveLocker2(config: {
|
|
|
209
209
|
readFiles: (files: FileInfo[]) => Promise<(Buffer | undefined)[]>,
|
|
210
210
|
) => Promise<ArchiveTransaction[]>
|
|
211
211
|
): Promise<"accepted" | "rejected"> {
|
|
212
|
-
let files = await locker.getFiles();
|
|
212
|
+
let files = await locker.getFiles({ forTransaction: true });
|
|
213
213
|
await saveSnapshot({ files: files.map(a => a.file) });
|
|
214
214
|
let readFiles = async (files: FileInfo[]) => {
|
|
215
215
|
let pendingFiles = files.slice();
|
|
@@ -494,21 +494,23 @@ class TransactionLocker {
|
|
|
494
494
|
let time = Date.now();
|
|
495
495
|
let files = await this.storage.getKeys(config);
|
|
496
496
|
this.perf.checkpoint("getKeys");
|
|
497
|
-
if (
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
497
|
+
if (!config?.fallbacks) {
|
|
498
|
+
if (this.lastFilesRead && this.lastFilesReadTime) {
|
|
499
|
+
let prevFiles = new Set(this.lastFilesRead.map(a => a.file));
|
|
500
|
+
let suspiciousThreshold = this.lastFilesReadTime - ARCHIVE_PROPAGATION_TIME * 10;
|
|
501
|
+
let newFiles = files.filter(a => !prevFiles.has(a.file));
|
|
502
|
+
let veryBadFiles = newFiles.filter(x => x.createTime < suspiciousThreshold);
|
|
503
|
+
if (veryBadFiles.length > 0) {
|
|
504
|
+
console.error(`Old read was not exhaustive, because we just found files which existed well before it, but that it did not read. This likely means our propagation assumptions are wrong, and propagation is much slower than anticipated. OR, getKeys is flakey and randomly misses files? Either way, this will BREAK THE DATABASE! Any node experiencing this might start deleting valid database files, which is very bad!`, {
|
|
505
|
+
newlyAppearingOldFiles: veryBadFiles.map(x => x.file),
|
|
506
|
+
prevFiles: this.lastFilesRead.map(x => x.file),
|
|
507
|
+
newFiles: files.map(x => x.file),
|
|
508
|
+
});
|
|
509
|
+
}
|
|
508
510
|
}
|
|
511
|
+
this.lastFilesRead = files;
|
|
512
|
+
this.lastFilesReadTime = time;
|
|
509
513
|
}
|
|
510
|
-
this.lastFilesRead = files;
|
|
511
|
-
this.lastFilesReadTime = time;
|
|
512
514
|
|
|
513
515
|
let transactions: (Transaction & {
|
|
514
516
|
seqNum: number;
|
|
@@ -794,7 +796,7 @@ class TransactionLocker {
|
|
|
794
796
|
/** Only returns data files (no transaction files, or confirmations).
|
|
795
797
|
* - Might run a transaction
|
|
796
798
|
*/
|
|
797
|
-
public async getFiles(): Promise<FileInfo[]> {
|
|
799
|
+
public async getFiles(config?: { forTransaction?: boolean }): Promise<FileInfo[]> {
|
|
798
800
|
let time = Date.now();
|
|
799
801
|
let storageAlivePromise = errorToUndefinedSilent(this.storage.getSyncStatus());
|
|
800
802
|
try {
|
|
@@ -805,7 +807,7 @@ class TransactionLocker {
|
|
|
805
807
|
return obj.dataFiles;
|
|
806
808
|
} catch (e) {
|
|
807
809
|
let duration0 = Date.now() - time;
|
|
808
|
-
if (await storageAlivePromise) {
|
|
810
|
+
if (config?.forTransaction || await storageAlivePromise) {
|
|
809
811
|
throw e;
|
|
810
812
|
}
|
|
811
813
|
let duration = Date.now() - time;
|
|
@@ -297,7 +297,7 @@ export async function runArchiveMover(config: {
|
|
|
297
297
|
console.log(" ");
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
const splitValuesBelowLimit = measureWrap(function splitValuesBelowLimit(config: {
|
|
300
|
+
export const splitValuesBelowLimit = measureWrap(function splitValuesBelowLimit(config: {
|
|
301
301
|
values: PathValue[];
|
|
302
302
|
maxFileValueCount: number;
|
|
303
303
|
maxFileByteCount: number;
|
|
@@ -2,7 +2,7 @@ import "../inject";
|
|
|
2
2
|
|
|
3
3
|
import { logErrors } from "../errors";
|
|
4
4
|
import { PathValueArchives, pathValueArchives } from "../0-path-value-core/pathValueArchives";
|
|
5
|
-
import { ARCHIVE_FLUSH_LIMIT, ARCHIVE_STABLE_THRESHOLD, PathValue } from "../0-path-value-core/pathValueCore";
|
|
5
|
+
import { ARCHIVE_FLUSH_LIMIT, ARCHIVE_STABLE_THRESHOLD, FILE_SIZE_LIMIT, FILE_VALUE_COUNT_LIMIT, PathValue } from "../0-path-value-core/pathValueCore";
|
|
6
6
|
import { runInfinitePollCallAtStart } from "socket-function/src/batching";
|
|
7
7
|
import { measureBlock } from "socket-function/src/profiling/measure";
|
|
8
8
|
import { pathValueSerializer } from "../-h-path-value-serialize/PathValueSerializer";
|
|
@@ -14,6 +14,7 @@ import { magenta } from "socket-function/src/formatting/logColors";
|
|
|
14
14
|
import { PathRouter } from "../0-path-value-core/PathRouter";
|
|
15
15
|
import { disablePathAuditer } from "../diagnostics/pathAuditerCallback";
|
|
16
16
|
import { getOurAuthoritySpec } from "../0-path-value-core/PathRouterServerAuthoritySpec";
|
|
17
|
+
import { splitValuesBelowLimit } from "../2-proxy/archiveMoveHarness";
|
|
17
18
|
import yargs from "yargs";
|
|
18
19
|
|
|
19
20
|
let yargObj = isNodeTrue() && yargs(process.argv)
|
|
@@ -101,18 +102,23 @@ async function runGenesisJoinIteration(config?: { force?: boolean }) {
|
|
|
101
102
|
|
|
102
103
|
let targets = await PathRouter.getPathIdentifierTargets(allCombinedValues, authoritySpec);
|
|
103
104
|
for (let [target, values] of targets) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
if (!dataObj) continue;
|
|
111
|
-
let newFileName = target + "/" + dataObj?.file;
|
|
112
|
-
transaction.createFiles.push({
|
|
113
|
-
file: newFileName,
|
|
114
|
-
data: dataObj.data,
|
|
105
|
+
let split = splitValuesBelowLimit({
|
|
106
|
+
values,
|
|
107
|
+
maxFileValueCount: FILE_VALUE_COUNT_LIMIT,
|
|
108
|
+
maxFileByteCount: FILE_SIZE_LIMIT,
|
|
115
109
|
});
|
|
110
|
+
for (let splitValues of split) {
|
|
111
|
+
let dataObj = await pathValueArchives.encodeValuePaths(splitValues.values, {
|
|
112
|
+
pathOverrides: {
|
|
113
|
+
sourceType: "join",
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
if (!dataObj) continue;
|
|
117
|
+
transaction.createFiles.push({
|
|
118
|
+
file: target + "/" + dataObj.file,
|
|
119
|
+
data: dataObj.data,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
console.log(magenta(`Joining ${formatNumber(usedFiles.length)} => ${transaction.createFiles.length} files with ${formatNumber(allCombinedValues.length)} values in ${formatNumber(totalSize)} bytes. Original count: ${formatNumber(originalCount)}, under path count: ${formatNumber(underPathCount)}, within time range count: ${formatNumber(withinTimeRangeCount)}`));
|