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 discarded enqueued queries #216

Merged
merged 1 commit into from Aug 29, 2023
Merged

Fix discarded enqueued queries #216

merged 1 commit into from Aug 29, 2023

Conversation

BobdenOs
Copy link
Contributor

Description

Currently it is possible to have Tasks which are queued while the database connection is in the process of being disconnected from the database. As the running Task is being rejected by the onend event it will trigger the next Task. This task is removed from the queue and send to the connection. Resulting in the connection becoming dormant and the started Task hanging. Additionally all queued Tasks are completely discarded when onclose is called. Which makes all the enqueued Tasks hang.

Visual examples

The current behavior:

sequenceDiagram
participant Connection
participant Queue
participant HANA

Connection->>Queue: Task 1
Connection->>Queue: Task 2
Queue->>Connection: run 1
Connection->>HANA: Task 1
HANA-->>Connection: Disconnect
Connection->>Queue: Task 1 (Error)
Queue->>Queue: next
Queue->>Connection: run 2
Connection->>HANA: Task 2
Connection->>Connection: Update Socket status

The behavior of the PR:

sequenceDiagram
participant Connection
participant Queue
participant HANA

Connection->>Queue: Task 1
Connection->>Queue: Task 2
Queue->>Connection: run 1
Connection->>HANA: Task 1
HANA-->>Connection: Disconnect
Connection->>Queue: Abort (Error)
Queue->>Queue: Task 2 (Error)
Connection->>Queue: Task 1 (Error)
Connection->>Connection: Update Socket Status

Alternative solution would be to call run in the next of the queue with setImmediate, but this might come with an performance impact for positive connection scenarios.

sequenceDiagram
participant Connection
participant Queue
participant HANA

Connection->>Queue: Task 1
Connection->>Queue: Task 2
Queue->>Connection: run 1
Connection->>HANA: Task 1
HANA-->>Connection: Disconnect
Connection->>Queue: Task 1 (Error)
Queue->>Queue: next (setImmediate)
Connection->>Connection: Update Socket Status
Queue->>Connection: run 2
Connection->>Queue: Task 2 (Error)

@cla-assistant
Copy link

cla-assistant bot commented Aug 24, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@IanMcCurdy IanMcCurdy left a comment

Choose a reason for hiding this comment

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

Change looks good, thank you for working on this fix!

@IanMcCurdy IanMcCurdy merged commit cccd888 into SAP:master Aug 29, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants