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

'Insufficient funds' error when doing multiple transfers at once #402

Open
michielbdejong opened this issue Mar 10, 2017 · 3 comments
Open

Comments

@michielbdejong
Copy link
Contributor

The postgresql database has conditions on its tables which mean that if multiple requests try to increase the balance of the 'hold' account simultaneously, some of those requests will fail with an SQL error which is something like one of the following:

  • { error: UPDATE "L_ACCOUNTS" SET "BALANCE" = "BALANCE" + $1 WHERE "NAME" = $2 - current transaction is aborted, commands ignored until end of transaction block
  • { error: UPDATE "L_ACCOUNTS" SET "BALANCE" = "BALANCE" + $1 WHERE "NAME" = $2 - could not serialize access due to read/write dependencies among transactions
  • ledger:error-handler error error: insert into "L_TRANSFERS" ("ADDITIONAL_INFO", "EXECUTION_CONDITION", "EXPIRES_DTTM", "LEDGER", "PROPOSED_DTTM", "STATUS_ID", "TRANSFER_UUID") values (DEFAULT, $1, $2, $3, $4, $5, $6) - could not serialize access due to read/write dependencies among transactions

This error is then "translated" to 'Sender has insufficient funds', even if the sender does have enough funds for the transfer they were attempting to send.

@michielbdejong
Copy link
Contributor Author

michielbdejong commented Mar 13, 2017

It seems this brings the ledger into a broken state, and even after restarting the host server, users will incorrectly be told they have insufficient funds. I'm also seeing non-zero balance of the hold account. -> seems it will be OK as long a you wait a bit before sending the next payment through the same ledger.

@michielbdejong
Copy link
Contributor Author

we talked about this at lunch, it would probably be more efficient to postpone any database writes until after a transfer has been fulfilled. If the ledger process crashes and comes back up, attempts to fulfill payments that were in flight since before the crash will fail, but this seems to be a small price to pay for getting way more ledger throughput and stability.

@michielbdejong
Copy link
Contributor Author

It seems this bug can be circumvented by leaving roughly 150ms between one payment and the next.

dappelt pushed a commit to interledgerjs/five-bells-integration-test that referenced this issue May 30, 2017
sleep was used to delay the test execution because of this issue: interledger-deprecated/five-bells-ledger#402
Since the issue is solved, the calls to sleep can be cleaned up.
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

No branches or pull requests

1 participant