querysub 0.17.0 → 0.18.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
|
@@ -22,6 +22,7 @@ import { getPublicIP } from "../misc/networking";
|
|
|
22
22
|
import dns from "dns/promises";
|
|
23
23
|
import { isDefined } from "../misc";
|
|
24
24
|
import { diskLog, noDiskLogPrefix } from "../diagnostics/logs/diskLogger";
|
|
25
|
+
import { getDebuggerUrl } from "../diagnostics/listenOnDebugger";
|
|
25
26
|
|
|
26
27
|
let HEARTBEAT_INTERVAL = timeInMinute * 2;
|
|
27
28
|
// Interval which we check other heartbeats
|
|
@@ -37,10 +38,16 @@ let SUICIDE_HEARTBEAT_THRESHOLD = timeInMinute * 15;
|
|
|
37
38
|
|
|
38
39
|
let CLIENTSIDE_POLL_RATE = timeInMinute * 5;
|
|
39
40
|
|
|
41
|
+
// We can't poll backblaze too often. One a minute starts to cost around 10 cents per month.
|
|
42
|
+
// So once a second would cost 6 USD per month, per service... which starts to get expensive.
|
|
43
|
+
let DISK_AUDIT_RATE = timeInMinute * 5;
|
|
44
|
+
// We CAN poll our API frequently. The overhead for calls should be far less than 1ms, and
|
|
45
|
+
// the bandwidth should also be effectively nothing. Maybe 2.5GB per month if we send a
|
|
46
|
+
// request per second, and each request is 1000 bytes (which as we use websockets, it
|
|
47
|
+
// probably is less than that). Which is around 2.5 cents on backblaze IF we go over
|
|
48
|
+
// our 1TB/month allowance.
|
|
40
49
|
let API_AUDIT_RATE = timeInSecond;
|
|
41
|
-
|
|
42
|
-
let MEMORY_AUDIT_RATE = timeInMinute * 5;
|
|
43
|
-
let MEMORY_AUDIT_COUNT = 3;
|
|
50
|
+
let API_AUDIT_COUNT = 12;
|
|
44
51
|
|
|
45
52
|
let shutdown = false;
|
|
46
53
|
|
|
@@ -161,6 +168,7 @@ function addNodeIdBase(nodeId: string) {
|
|
|
161
168
|
}
|
|
162
169
|
function setNodeIds(nodeIds: string[]) {
|
|
163
170
|
nodeIds = nodeIds.filter(x => x !== SPECIAL_NODE_ID_FOR_UNMOUNTED_NODE);
|
|
171
|
+
|
|
164
172
|
diskLog("setNodeIds", { nodeIds });
|
|
165
173
|
// Also try all localhost ports, if we are in dev mode
|
|
166
174
|
if (isNode() && isDevDebugbreak()) {
|
|
@@ -285,14 +293,15 @@ async function runHeartbeatAuditLoop() {
|
|
|
285
293
|
}
|
|
286
294
|
|
|
287
295
|
async function fastMemorySync() {
|
|
288
|
-
let checkNodes = shuffle(Array.from(allNodeIds2).filter(x => x !== getOurNodeId()), Date.now()).slice(0,
|
|
296
|
+
let checkNodes = shuffle(Array.from(allNodeIds2).filter(x => x !== getOurNodeId()), Date.now()).slice(0, API_AUDIT_COUNT);
|
|
289
297
|
let otherNodesAll = await Promise.all(
|
|
290
298
|
checkNodes.map(async nodeId =>
|
|
291
299
|
await timeoutToUndefinedSilent(200, NodeDiscoveryController.nodes[nodeId].getAllNodeIds()) || []
|
|
292
300
|
)
|
|
293
301
|
);
|
|
294
302
|
let otherNodes = Array.from(new Set(otherNodesAll.flat()));
|
|
295
|
-
//
|
|
303
|
+
// This would log WAY too much, because we poll a lot, because we want to minimize downtime
|
|
304
|
+
//console.log(magenta(`Fast memory sync at ${formatVeryNiceDateTime(Date.now())}, nodes found ${otherNodes.length}`), getDebuggerUrl());
|
|
296
305
|
|
|
297
306
|
// If they are missing nodes that's fine. We constantly have extra nodes, and have to function correctly
|
|
298
307
|
// with extra nodes. However, if we are missing nodes, we'd prefer to have them quickly, so we should
|
|
@@ -306,7 +315,7 @@ async function fastMemorySync() {
|
|
|
306
315
|
|
|
307
316
|
async function runMemoryAuditLoop() {
|
|
308
317
|
await onNodeDiscoveryReady();
|
|
309
|
-
runInfinitePoll(
|
|
318
|
+
runInfinitePoll(DISK_AUDIT_RATE, syncArchives);
|
|
310
319
|
runInfinitePoll(API_AUDIT_RATE, fastMemorySync);
|
|
311
320
|
}
|
|
312
321
|
|