merge: Sync charts one-at-a-time to reduce database contention and timeouts (!830)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/830 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Charlotte <timo.herngreen@gmail.com>
This commit is contained in:
commit
0c123d04d6
4 changed files with 32 additions and 38 deletions
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue