enhance(backend): チャートの処理を一つずつ行うことでDBの同時接続とタイムアウトを削減 (#15239)
* sync charts one-at-a-time to reduce database contention and timeouts * fix merge resolve failure * Update Changelog * update changelog * add comments --------- Co-authored-by: Hazelnoot <acomputerdog@gmail.com>
This commit is contained in:
@@ -58,9 +58,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();
|
||||
}
|
||||
}, 1000 * 60 * 20);
|
||||
}
|
||||
@@ -69,9 +69,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user