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: Insert channel params before posting new order #2056

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

holzeis
Copy link
Contributor

@holzeis holzeis commented Feb 17, 2024

I am not exactly sure why this is fixing the issue, but my assumption is the following.

If we receive the order match (async via websockets) before the post_new_order http request has finished. We'd still hold an open connection and the write lock on the order.

I presume this leads to the order match processing to fail because of Could not load order from db: cannot acquire database connection: timed out waiting for connection. But I am not sure why that would result into the processing of the order match running into a timeout when trying to get a connection.

When the post_new_order finally finishes the lock is freed up. I guess afterwards the pool would return connections again but we are already stuck because we do not send the trade request anymore (since processing the match already failed)

Additionally I had to remove the order_id check on the submit_order_change_notifier, since it could happen that we don't have the id yet if the order match is already processed before the http post new order request finished. IMHO that should be fine because we only ever have one active order anyways and we don't have to separate them.

fixes #2055

@holzeis holzeis self-assigned this Feb 17, 2024
@holzeis holzeis force-pushed the fix/post-order-operation-timeout branch from 3e2fe6b to 76227bc Compare February 17, 2024 10:54
@holzeis
Copy link
Contributor Author

holzeis commented Feb 17, 2024

@luckysori I've addressed your remarks! Please have another look cd1cb10

Copy link
Contributor

@luckysori luckysori left a comment

Choose a reason for hiding this comment

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

LGTM. A couple of minor things. Thanks for fixing this bug!

CHANGELOG.md Outdated Show resolved Hide resolved
mobile/native/src/trade/order/handler.rs Outdated Show resolved Hide resolved
@holzeis holzeis force-pushed the fix/post-order-operation-timeout branch from da0c34c to afa3f39 Compare February 19, 2024 07:23
@holzeis holzeis changed the title fix: Commit db transaction before posting new order fix: Insert channel params before posting new order Feb 19, 2024
… the coordinator

I am not exactly sure why this is fixing the issue, but my assumption is the following.

If we receive the order match (async via websockets) before the post_new_order http request has finished. We'd still hold an open connection and the write lock on the order.

I presume this leads to the order match processing to fail because of Could not load order from db: cannot acquire database connection: timed out waiting for connection. But I am not sure why that would result into the processing of the order match running into a timeout when trying to get a connection.

When the post_new_order finally finishes the lock is freed up. I guess afterwards the pool would return connections again but we are already stuck because we do not send the trade request anymore (since processing the match already failed)

Additionally I had to remove the order_id check on the submit_order_change_notifier, since it could happen that we don't have the id yet if the order match is already processed before the http post new order request finished. IMHO that should be fine because we only ever have one active order anyways and we don't have to separate them.

fixes #2055
@holzeis holzeis force-pushed the fix/post-order-operation-timeout branch from afa3f39 to bc1bcd8 Compare February 19, 2024 07:33
@holzeis holzeis added this pull request to the merge queue Feb 19, 2024
Merged via the queue into main with commit f102515 Feb 19, 2024
18 of 19 checks passed
@holzeis holzeis deleted the fix/post-order-operation-timeout branch February 19, 2024 07:48
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.

Failed to post new order: operation timed out
2 participants