-
Notifications
You must be signed in to change notification settings - Fork 33
Description
I became lightly concerned when I noticed how many balances in the receivable table can turn negative. I saw it in data I got from Syther and it was actually a very short test attempt (not as long as planned, probably), maximally a span of three payments could snap in the simulated network made up of six Nodes - yet it resulted in negative balances in almost all databases I looked into in this group. (It's worth a note that despite the concerning nature of the previous statement I had a chance to examine data after a much bigger test, with hundreds of payments, and I saw a significantly fewer occurrence of the negative numbers, which is positive indeed. Anyway, even there, some could be found.)
It just made me wonder how frequent is this phenomenon and whether we actually can get a picture of what's going on there. Therefore, I was thinking that a modification of the BigIntProcessor that takes care of decomposition of the huge integers we use for accounting into two i64 integers that can be natively stored in a SQLite DB. Using the RETURNING clause could allow us to see immediately the result in the column after the modification having taken place. I think it might be good to know if we go negative and how much. Even if we don't have a better use than logging it for forensic analysis, we might want to react more proactively in the future... however, I can only think of situation when we'd compensate them by sending them this money back together with what we keep in their payable account (I think, a card about this probably exists).
I feel like I can go ahead and implement it, because, based on my research, the returning clause has a minimal overhead. It's definitely less than adding a SELECT. Plus, I plan to design it so that the BigIntProcessor can be configured and this return value may be opted out at places where we don't care - since I'm actually interested only in the receivables. For the rest of those places, the overhead of this solution will become absolutely negligible.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status