Open altergui opened 1 year ago
FYI, Indexer.Commit
will get dramatically faster on the sqlite side over the next week or so, so I would say wait until that's finished - it might be enough for the foreseeable future. Adding more goroutines is very risky, because more often than not, that adds all kinds of races and correctness issues unless we're very, very careful.
For reference, I mean faster via changes like https://github.com/vocdoni/vocdoni-node/pull/906. In short, doing more work upfront so that Commit doesn't need to execute queries, and using one transaction for all changes to be committed.
@altergui let's see if Mvdan's optimizations fix this issue.
right now the indexer Commit():
step 1 might take significant time (1 second, seen in CI), during this interval any queries to accounts return the outdated balances.
that indexing maybe can be optimized to take milliseconds instead of seconds, but that will simply push the problem forward, to 10000 votes per block instead of 100 votes per block.
one very simple solution would be to hold a Lock, so that all reads are blocked until Commit finishes. right now this is not the case, only RLock is held.
problem is, Commit is called synchronously
so the refactor should include turning that into a goroutine. this might bring other consecuences, tho. careful redesign is needed.