@hot-updater/server 1.2.0-rc.58 → 1.2.0-rc.59
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/core/labels.cjs +9 -1
- package/dist/core/labels.mjs +10 -2
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +6 -6
package/dist/core/labels.cjs
CHANGED
|
@@ -68,6 +68,9 @@ const createLabelAllocator = (tx, used, caughtUp) => {
|
|
|
68
68
|
};
|
|
69
69
|
const FILL_BATCH = 25;
|
|
70
70
|
const PAGE = 500;
|
|
71
|
+
const PAUSE_MS = 1e3;
|
|
72
|
+
const MAX_PAUSE_MS = 32e3;
|
|
73
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
71
74
|
/**
|
|
72
75
|
* Labels a channel and platform's releases that have none, in ID order,
|
|
73
76
|
* which is the order they were created in, and marks its counter filled:
|
|
@@ -79,6 +82,7 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
79
82
|
const id = labelSequenceId(channelId, platform);
|
|
80
83
|
let labeled = 0;
|
|
81
84
|
let batchSize = FILL_BATCH;
|
|
85
|
+
let paused = 0;
|
|
82
86
|
const label = async (ids) => {
|
|
83
87
|
for (let at = 0; at < ids.length;) {
|
|
84
88
|
const batch = ids.slice(at, at + batchSize);
|
|
@@ -103,12 +107,16 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
103
107
|
return count;
|
|
104
108
|
});
|
|
105
109
|
at += batch.length;
|
|
110
|
+
paused = 0;
|
|
106
111
|
} catch (error) {
|
|
107
112
|
if (batchSize > 1 && error instanceof _hot_updater_plugin_core.DatabaseConstraintError && error.reason === "too_large") {
|
|
108
113
|
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
109
114
|
continue;
|
|
110
115
|
}
|
|
111
|
-
throw error;
|
|
116
|
+
if (!(0, _hot_updater_plugin_core.isDatabaseBusyError)(error) || paused >= MAX_PAUSE_MS) throw error;
|
|
117
|
+
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
118
|
+
paused = paused === 0 ? PAUSE_MS : paused * 2;
|
|
119
|
+
await sleep(paused);
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
};
|
package/dist/core/labels.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toReleaseRow } from "./reads.mjs";
|
|
2
|
-
import { DatabaseConstraintError } from "@hot-updater/plugin-core";
|
|
2
|
+
import { DatabaseConstraintError, isDatabaseBusyError } from "@hot-updater/plugin-core";
|
|
3
3
|
//#region src/core/labels.ts
|
|
4
4
|
/**
|
|
5
5
|
* The counter of a channel and platform's release labels: one
|
|
@@ -68,6 +68,9 @@ const createLabelAllocator = (tx, used, caughtUp) => {
|
|
|
68
68
|
};
|
|
69
69
|
const FILL_BATCH = 25;
|
|
70
70
|
const PAGE = 500;
|
|
71
|
+
const PAUSE_MS = 1e3;
|
|
72
|
+
const MAX_PAUSE_MS = 32e3;
|
|
73
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
71
74
|
/**
|
|
72
75
|
* Labels a channel and platform's releases that have none, in ID order,
|
|
73
76
|
* which is the order they were created in, and marks its counter filled:
|
|
@@ -79,6 +82,7 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
79
82
|
const id = labelSequenceId(channelId, platform);
|
|
80
83
|
let labeled = 0;
|
|
81
84
|
let batchSize = FILL_BATCH;
|
|
85
|
+
let paused = 0;
|
|
82
86
|
const label = async (ids) => {
|
|
83
87
|
for (let at = 0; at < ids.length;) {
|
|
84
88
|
const batch = ids.slice(at, at + batchSize);
|
|
@@ -103,12 +107,16 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
103
107
|
return count;
|
|
104
108
|
});
|
|
105
109
|
at += batch.length;
|
|
110
|
+
paused = 0;
|
|
106
111
|
} catch (error) {
|
|
107
112
|
if (batchSize > 1 && error instanceof DatabaseConstraintError && error.reason === "too_large") {
|
|
108
113
|
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
109
114
|
continue;
|
|
110
115
|
}
|
|
111
|
-
throw error;
|
|
116
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS) throw error;
|
|
117
|
+
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
118
|
+
paused = paused === 0 ? PAUSE_MS : paused * 2;
|
|
119
|
+
await sleep(paused);
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
};
|
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/server",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.59",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"rou3": "0.7.9",
|
|
52
52
|
"verkit": "0.4.0",
|
|
53
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
54
|
-
"@hot-updater/plugin-
|
|
55
|
-
"@hot-updater/plugin-
|
|
56
|
-
"@hot-updater/plugin-remote-config": "1.2.0-rc.
|
|
57
|
-
"@hot-updater/plugin-api-keys": "1.2.0-rc.
|
|
53
|
+
"@hot-updater/protocol": "1.2.0-rc.59",
|
|
54
|
+
"@hot-updater/plugin-insights": "1.2.0-rc.59",
|
|
55
|
+
"@hot-updater/plugin-core": "1.2.0-rc.59",
|
|
56
|
+
"@hot-updater/plugin-remote-config": "1.2.0-rc.59",
|
|
57
|
+
"@hot-updater/plugin-api-keys": "1.2.0-rc.59"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@prisma/client": "*",
|