interledger-rs icon indicating copy to clipboard operation
interledger-rs copied to clipboard

Recover from crashes after updating balances for prepare (before fulfill is received)

Open gakonst opened this issue 5 years ago • 0 comments

FWIW, the reason I originally had these other values here was to allow for better ways of accounting for the balance. This store isn't doing proper accounting right now. If the server crashes after update_balances_for_prepare but before the fulfillment is received, the money from the from account will effectively disappear. A better way to do it would be to put that money (atomically) into another account, from which it would be transferred when the fulfillment comes in. One thing I'm not sure about is whether that pending balance would be linked to the from account, to the from and to accounts (meaning there would be a separate row for pending balance between any pairs of accounts, which doesn't seem great), or neither.

We could do it like a 2phase commit, the prepare would decrease 'from' and increase 'to' temporary fields, and on fulfil it would apply them to the actual state.

_Originally posted by @emschwartz in https://github.com/render_node/MDE3OlB1bGxSZXF1ZXN0UmV2aWV3MjY3ODEyOTAz/pull_request_reviews/more_threads

gakonst avatar Jul 29 '19 18:07 gakonst