summaryrefslogtreecommitdiff
path: root/packages/backend/src/core
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2024-12-17 10:37:29 -0500
committerHazelnoot <acomputerdog@gmail.com>2024-12-17 10:37:29 -0500
commit0b40f2734eff04e1719dc18fcbe70f2cfc97ee76 (patch)
tree7e418dcd64963d1a5c0f65721274e8606971c916 /packages/backend/src/core
parentmerge: upstream changes for 2024.11 (!742) (diff)
downloadsharkey-0b40f2734eff04e1719dc18fcbe70f2cfc97ee76.tar.gz
sharkey-0b40f2734eff04e1719dc18fcbe70f2cfc97ee76.tar.bz2
sharkey-0b40f2734eff04e1719dc18fcbe70f2cfc97ee76.zip
sync charts one-at-a-time to reduce database contention and timeouts
Diffstat (limited to 'packages/backend/src/core')
-rw-r--r--packages/backend/src/core/chart/ChartManagementService.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/backend/src/core/chart/ChartManagementService.ts b/packages/backend/src/core/chart/ChartManagementService.ts
index 316feec6ee..ef65af2432 100644
--- a/packages/backend/src/core/chart/ChartManagementService.ts
+++ b/packages/backend/src/core/chart/ChartManagementService.ts
@@ -63,9 +63,9 @@ export class ChartManagementService implements OnApplicationShutdown {
@bindThis
public async start() {
// 20分おきにメモリ情報をDBに書き込み
- this.saveIntervalId = setInterval(() => {
+ this.saveIntervalId = setInterval(async () => {
for (const chart of this.charts) {
- chart.save();
+ await chart.save();
}
this.logger.info('All charts saved');
}, 1000 * 60 * 20);
@@ -75,9 +75,9 @@ export class ChartManagementService implements OnApplicationShutdown {
public async dispose(): Promise<void> {
clearInterval(this.saveIntervalId);
if (process.env.NODE_ENV !== 'test') {
- await Promise.all(
- this.charts.map(chart => chart.save()),
- );
+ for (const chart of this.charts) {
+ await chart.save();
+ }
this.logger.info('All charts saved');
}
}