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

[backend] keep increasing back pressure delay if queue size keeps increasing (#9358) #9555

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from all 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
13 changes: 8 additions & 5 deletions opencti-platform/opencti-graphql/src/manager/syncManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@
const manageBackPressure = async (httpClient, { uri }, currentDelay) => {
if (connectionId) {
const connectionManagement = `${httpBase(uri)}stream/connection/${connectionId}`;
if (currentDelay === lDelay && eventsQueue.getLength() > MAX_QUEUE_SIZE) {
await httpClient.post(connectionManagement, { delay: hDelay });
logApp.info(`[OPENCTI] Sync ${syncId}: connection setup to use ${hDelay} delay`);
return hDelay;
const currentQueueLength = eventsQueue.getLength();
// If queue length keeps increasing even with an increased delay, we keep increasing the delay until we are able to go back below MIN_QUEUE_SIZE
if (currentQueueLength > MAX_QUEUE_SIZE && currentDelay * MAX_QUEUE_SIZE < hDelay * (currentQueueLength - MAX_QUEUE_SIZE)) {
const newDelay = currentDelay + hDelay;
await httpClient.post(connectionManagement, { delay: newDelay });
logApp.info(`[OPENCTI] Sync ${syncId}: connection setup to use ${newDelay} delay`);
return newDelay;

Check warning on line 73 in opencti-platform/opencti-graphql/src/manager/syncManager.js

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/manager/syncManager.js#L67-L73

Added lines #L67 - L73 were not covered by tests
}
if (currentDelay === hDelay && eventsQueue.getLength() < MIN_QUEUE_SIZE) {
if (currentQueueLength < MIN_QUEUE_SIZE && currentDelay !== lDelay) {

Check warning on line 75 in opencti-platform/opencti-graphql/src/manager/syncManager.js

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/manager/syncManager.js#L75

Added line #L75 was not covered by tests
await httpClient.post(connectionManagement, { delay: lDelay });
logApp.info(`[OPENCTI] Sync ${syncId}: connection setup to use ${lDelay} delay`);
return lDelay;
Expand Down
Loading