Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interval with 0 time causing high CPU #2614

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/query/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- High CPU usage caused by interval with 0ms (#2614)

## [2.17.1] - 2024-11-28
### Fixed
Expand Down
4 changes: 3 additions & 1 deletion packages/query/src/graphql/graphql.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export class GraphqlModule implements OnModuleInit, OnModuleDestroy {
}

private setupKeepAlive(pgClient: PoolClient) {
const interval = argv['sl-keep-alive-interval'] ?? 180000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should use ||

logger.info(`Setup PG Pool keep alive. interval ${interval} ms`);
setInterval(() => {
void (async () => {
try {
Expand All @@ -126,7 +128,7 @@ export class GraphqlModule implements OnModuleInit, OnModuleDestroy {
getLogger('db').error('Schema listener client keep-alive query failed: ', err);
}
})();
}, this.config.get('sl-keep-alive-interval'));
}, interval);
}

private async createServer() {
Expand Down
Loading