Skip to content

Commit

Permalink
Fix interval with 0 time causing high CPU (#2614)
Browse files Browse the repository at this point in the history
* Fix interval with 0 time causing high CPU

* Update changelog

* Update fallback check
  • Loading branch information
stwiname authored Dec 2, 2024
1 parent ba33f6b commit 8027f34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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;
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

0 comments on commit 8027f34

Please sign in to comment.