Repository navigation
Keep auto top-up invoices when billing e-invoicing is slow - #2988
Open
OlegPhenomenon wants to merge 1 commit into
Open
OlegPhenomenon wants to merge 1 commit into
OlegPhenomenon wants to merge 1 commit into
Conversation
registrars:reload_balance sent the e-invoice synchronously inside a DB transaction wrapping all registrars. A 60s billing response caused Net::ReadTimeout, rolled back the registry invoice while billing kept it, and the next run issued a duplicate invoice. - Enqueue SendEInvoiceJob instead of performing it inline - SendEInvoiceJob skips invoices that no longer exist - Drop the outer transaction; a failing registrar no longer rolls back others - e_invoice_response returns JSON 404 for unknown invoices instead of a 500 HTML page Refs #2948
Contributor
🚀 Deploy Complete!
(Environment ready for testing) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On 23.07
registrars:reload_balanceissued an auto top-up invoice (144677). It then sent the e-invoice to Billing synchronously, inside a DB transaction that wrapped all registrars.SendEInvoiceJob.set(wait: 1.minute).perform_nowignoreswait. Billing waited 60.5 seconds for Omniva, the registry gotNet::ReadTimeoutand the transaction rolled the invoice back. Billing kept it and sent the e-invoice. The next run issued 144678, and the payment for 144677 arrived for an invoice the registry didn't have.Side error: Billing's
e_invoice_responsecallback for 144677 hitnil.updateinEInvoiceResponseController. The registry returned a 500 HTML page, and Billing failed withJSON::ParserError: unexpected character: '<!DOCTYPE'.The Billing side, which no longer waits for Omniva inside the request, is in internetee/eis_billing_system#274.
Changes
Registrar#issue_prepayment_invoiceenqueuesSendEInvoiceJobwithperform_laterinstead of running it withperform_now. This covers every caller: the auto top-up task, admin and REPP add credit.SendEInvoiceJobusesfind_byinstead offind, so a job for an invoice whose transaction was rolled back does nothing instead of retrying in Sidekiq.registrars:reload_balanceno longer has the transaction around the whole loop. A failure for one registrar is printed to the cron log and the rest carry on. Invoice creation and thependingflag are still in one transaction.PUT /eis_billing/e_invoice_responsereturns a JSON 404 for an unknown invoice.Not changed
GetInvoiceNumberandAddDepositsstill run inside the top-up transaction. They are fast because the EveryPay link is generated locally. Moving them out means changingissue_prepayment_invoicefor all callers.sent_at_omnivawould block auction's manual "send e-invoice" button. The registry already skips invoices that were sent, throughdo_not_send_e_invoice?.Tests
test/tasks/registrars/reload_balance_test.rb:test/integration/eis_billing/e_invoice_response_test.rb: an unknown invoice gets a JSON 404.Closes #2948