mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-29 13:59:26 +01:00
sync charts one-at-a-time to reduce database contention and timeouts
This commit is contained in:
parent
e2352839e4
commit
0b40f2734e
4 changed files with 32 additions and 38 deletions
|
@ -63,9 +63,9 @@ export class ChartManagementService implements OnApplicationShutdown {
|
||||||
@bindThis
|
@bindThis
|
||||||
public async start() {
|
public async start() {
|
||||||
// 20分おきにメモリ情報をDBに書き込み
|
// 20分おきにメモリ情報をDBに書き込み
|
||||||
this.saveIntervalId = setInterval(() => {
|
this.saveIntervalId = setInterval(async () => {
|
||||||
for (const chart of this.charts) {
|
for (const chart of this.charts) {
|
||||||
chart.save();
|
await chart.save();
|
||||||
}
|
}
|
||||||
this.logger.info('All charts saved');
|
this.logger.info('All charts saved');
|
||||||
}, 1000 * 60 * 20);
|
}, 1000 * 60 * 20);
|
||||||
|
@ -75,9 +75,9 @@ export class ChartManagementService implements OnApplicationShutdown {
|
||||||
public async dispose(): Promise<void> {
|
public async dispose(): Promise<void> {
|
||||||
clearInterval(this.saveIntervalId);
|
clearInterval(this.saveIntervalId);
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
await Promise.all(
|
for (const chart of this.charts) {
|
||||||
this.charts.map(chart => chart.save()),
|
await chart.save();
|
||||||
);
|
}
|
||||||
this.logger.info('All charts saved');
|
this.logger.info('All charts saved');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,20 +48,18 @@ export class CleanChartsProcessorService {
|
||||||
public async process(): Promise<void> {
|
public async process(): Promise<void> {
|
||||||
this.logger.info('Clean charts...');
|
this.logger.info('Clean charts...');
|
||||||
|
|
||||||
await Promise.all([
|
await this.federationChart.clean();
|
||||||
this.federationChart.clean(),
|
await this.notesChart.clean();
|
||||||
this.notesChart.clean(),
|
await this.usersChart.clean();
|
||||||
this.usersChart.clean(),
|
await this.activeUsersChart.clean();
|
||||||
this.activeUsersChart.clean(),
|
await this.instanceChart.clean();
|
||||||
this.instanceChart.clean(),
|
await this.perUserNotesChart.clean();
|
||||||
this.perUserNotesChart.clean(),
|
await this.perUserPvChart.clean();
|
||||||
this.perUserPvChart.clean(),
|
await this.driveChart.clean();
|
||||||
this.driveChart.clean(),
|
await this.perUserReactionsChart.clean();
|
||||||
this.perUserReactionsChart.clean(),
|
await this.perUserFollowingChart.clean();
|
||||||
this.perUserFollowingChart.clean(),
|
await this.perUserDriveChart.clean();
|
||||||
this.perUserDriveChart.clean(),
|
await this.apRequestChart.clean();
|
||||||
this.apRequestChart.clean(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
this.logger.succ('All charts successfully cleaned.');
|
this.logger.succ('All charts successfully cleaned.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,9 @@ export class ResyncChartsProcessorService {
|
||||||
|
|
||||||
// TODO: ユーザーごとのチャートも更新する
|
// TODO: ユーザーごとのチャートも更新する
|
||||||
// TODO: インスタンスごとのチャートも更新する
|
// TODO: インスタンスごとのチャートも更新する
|
||||||
await Promise.all([
|
await this.driveChart.resync();
|
||||||
this.driveChart.resync(),
|
await this.notesChart.resync();
|
||||||
this.notesChart.resync(),
|
await this.usersChart.resync();
|
||||||
this.usersChart.resync(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
this.logger.succ('All charts successfully resynced.');
|
this.logger.succ('All charts successfully resynced.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,20 +48,18 @@ export class TickChartsProcessorService {
|
||||||
public async process(): Promise<void> {
|
public async process(): Promise<void> {
|
||||||
this.logger.info('Tick charts...');
|
this.logger.info('Tick charts...');
|
||||||
|
|
||||||
await Promise.all([
|
await this.federationChart.tick(false);
|
||||||
this.federationChart.tick(false),
|
await this.notesChart.tick(false);
|
||||||
this.notesChart.tick(false),
|
await this.usersChart.tick(false);
|
||||||
this.usersChart.tick(false),
|
await this.activeUsersChart.tick(false);
|
||||||
this.activeUsersChart.tick(false),
|
await this.instanceChart.tick(false);
|
||||||
this.instanceChart.tick(false),
|
await this.perUserNotesChart.tick(false);
|
||||||
this.perUserNotesChart.tick(false),
|
await this.perUserPvChart.tick(false);
|
||||||
this.perUserPvChart.tick(false),
|
await this.driveChart.tick(false);
|
||||||
this.driveChart.tick(false),
|
await this.perUserReactionsChart.tick(false);
|
||||||
this.perUserReactionsChart.tick(false),
|
await this.perUserFollowingChart.tick(false);
|
||||||
this.perUserFollowingChart.tick(false),
|
await this.perUserDriveChart.tick(false);
|
||||||
this.perUserDriveChart.tick(false),
|
await this.apRequestChart.tick(false);
|
||||||
this.apRequestChart.tick(false),
|
|
||||||
]);
|
|
||||||
|
|
||||||
this.logger.succ('All charts successfully ticked.');
|
this.logger.succ('All charts successfully ticked.');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue