Do not perform external calls during a database transaction. #954

Merged
crodas merged 2 commits from feature/move-external-calls-without-tx into main 2025-08-13 11:25:59 +00:00
crodas commented 2025-08-12 13:24:55 +00:00 (Migrated from github.com)

Description

The codebase was used to correctly perform signatory calls during a database transaction, as the signatory was previously exclusively in process. However, a few months ago, it was changed to be a trait that can be either local or remote. Making external calls to services, adding latency, during an ongoing database transaction is a bad idea because it will lock the rows until the service call is finalized, which is unpredictable.

The issue is even worse in our pipeline where the SQLite storage driver is used with the ":memory:" path, which forces the Database pool to have a size of 1. Since our tests run in parallel, they would randomly fail.

This issue was failing in the CI, but the error was not making the pipeline fail. This bug was fixed as well.


Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

### Description The codebase was used to correctly perform signatory calls during a database transaction, as the signatory was previously exclusively in process. However, a few months ago, it was changed to be a trait that can be either local or remote. Making external calls to services, adding latency, during an ongoing database transaction is a bad idea because it will lock the rows until the service call is finalized, which is unpredictable. The issue is even worse in our pipeline where the SQLite storage driver is used with the ":memory:" path, which forces the Database pool to have a size of 1. Since our tests run in parallel, they would randomly fail. This issue was failing in the CI, but the error was not making the pipeline fail. This bug was fixed as well. ----- ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ----- ### Suggested [CHANGELOG](https://github.com/cashubtc/cdk/blob/main/CHANGELOG.md) Updates <!-- Please do not edit the actual changelog but note what you changed here. --> #### CHANGED #### ADDED #### REMOVED #### FIXED ---- ### Checklist * [ ] I followed the [code style guidelines](https://github.com/cashubtc/cdk/blob/main/CODE_STYLE.md) * [ ] I ran `just final-check` before committing
thesimplekid (Migrated from github.com) reviewed 2025-08-13 07:49:26 +00:00
thesimplekid (Migrated from github.com) commented 2025-08-13 07:39:53 +00:00

Is this right? I think it should only be sqlite and why is it included in this pr?

Is this right? I think it should only be sqlite and why is it included in this pr?
thesimplekid (Migrated from github.com) reviewed 2025-08-13 07:51:05 +00:00
thesimplekid (Migrated from github.com) commented 2025-08-13 07:51:04 +00:00
Looks like https://github.com/cashubtc/cdk/pull/953 was wrong
thesimplekid (Migrated from github.com) reviewed 2025-08-13 08:00:55 +00:00
thesimplekid (Migrated from github.com) commented 2025-08-13 08:00:55 +00:00
should be fixed by https://github.com/cashubtc/cdk/pull/956
thesimplekid (Migrated from github.com) reviewed 2025-08-13 09:57:19 +00:00
thesimplekid (Migrated from github.com) commented 2025-08-13 09:57:14 +00:00

I think you'll just need to manually delete this change and force push

I think you'll just need to manually delete this change and force push
crodas (Migrated from github.com) reviewed 2025-08-13 10:05:25 +00:00
crodas (Migrated from github.com) commented 2025-08-13 10:05:25 +00:00

Done

Done
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cashubtc/cdk!954
No description provided.