This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Approval Voting: Refactor Action
s to be less racy and fragile
#3311
Labels
I8-refactor
Code needs refactoring.
Problem Statement
At the moment, in approval voting, we use a system of
Action
s for logic to trigger writes to the DB within the smaller functions that perform the actual logic of reading from the DB. The problem is that a function may be called a second time before the actions of the first time have been written, and therefore read outdated data from the DB and produce an incoherent write. More generally, the can arise when calling functions A and B successively without applying theAction
s from A before calling B.In minimized pseudocode:
The
Backend
pattern used in #3277 represents a pretty good fix. Instead of passing around aDbReader
and producing actions to be put into aDbWriter
, we instead pass around anOverlayedBackend
which incrementally will build up a set of operations to be committed at the end. We should do the same here, but also be aware that the approval-db may be going away soon so our backend trait may need to become async so we can fetch the data from a dedicated DB subsystem.The text was updated successfully, but these errors were encountered: