-
Notifications
You must be signed in to change notification settings - Fork 90
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(backend): deadlocks #3320
base: main
Are you sure you want to change the base?
fix(backend): deadlocks #3320
Conversation
- fixes deadlocks by ensuring we dont open new connections before resolving open transactions - forced knex connections to 1 to help find these cases
✅ Deploy Preview for brilliant-pasca-3e80ec canceled.
|
- payment returned from createOutgoingPayment previously had walletAddress of undefined (coming from withGraphFetched(quote)). When assigning manually it included wallet address. Updated get methods to include wallet address on quote as well.
// TODO: should getQuote happen inside trx? wasnt in main (was inside but not using trx). | ||
// If so, in the getQuote method, need to not only pass into IlpQuoteDetails but also connector. | ||
// Probably should have IlpQuoteDetails usingt he trx but not sure about the rest (just | ||
// including the IlpQuoteDetails insert would prly require refactor to to that here) | ||
const quote = await deps.paymentMethodHandlerService.getQuote( | ||
paymentMethod, | ||
{ | ||
quoteId, | ||
walletAddress, | ||
receiver, | ||
receiveAmount: options.receiveAmount, | ||
debitAmount: options.debitAmount | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something still needs to be done here one way or another.
-
return ilp quote details from get quote and save in transaction with quote insert. This assumes the ilp connector db calls do not need to use the transaction (they are not using it on main). This should be more performant as it greatly reduces the duration of the transaction. However it does leak the ilp payment method concern into quotes.
-
Do this in the transaction. Pass the transaction into the connector and use for all the db calls.
Originally we called this inside the transaction. The transaction was passed in but only used to save the IlpQuoteDetails
. It was not used by the connector. This getQuote
is a heavy operation (for ilp payments) because of all the db/network calls so it would be nice not to include it in the transaction provided its safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea for 1. is a new saveAdditionalDetails(trx: Knex.Transction, quote: Quote)
method on the paymentMethodHandlerService
that inserts into IlpQuoteDetails
for the ilp paymnet method, and does nothing for local payments. Keeps the ilp quote details encapsulated in the ilp payment method handler.
quote: UnfinalizedQuote, | ||
receiver: Receiver | ||
): Date { | ||
const quoteExpiry = new Date(Date.now() + deps.config.quoteLifespan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creates an expiry of now, instead of createdAt
(since we are setting ahead of creation). This was to allow us to simply create the quote and not create then update it.
Changes proposed in this pull request
Date.now()
before creating instead ofquote.createdAt
)Context
fixes #3319 #3226
Checklist
fixes #number
user-docs
label (if necessary)