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

Finish marking CVR export as complete before setting polls store state to closed in backend polls-close handler #4792

Open
arsalansufi opened this issue Apr 24, 2024 · 0 comments

Comments

@arsalansufi
Copy link
Contributor

arsalansufi commented Apr 24, 2024

Relevant handler:

export async function closePolls({
workspace,
usbDrive,
logger,
}: {
workspace: Workspace;
usbDrive: UsbDrive;
logger: Logger;
}): Promise<void> {
const { store } = workspace;
const previousPollsState = store.getPollsState();
assert(
previousPollsState === 'polls_open' || previousPollsState === 'polls_paused'
);
store.transitionPolls({ type: 'close_polls', time: getCurrentTime() });
await logger.logAsCurrentRole(LogEventId.PollsClosed, {
disposition: 'success',
message: 'User closed the polls.',
});
if (previousPollsState === 'polls_open') {
const ongoingBatchId = store.getOngoingBatchId();
assert(ongoingBatchId !== undefined);
store.finishBatch({ batchId: ongoingBatchId });
await logger.log(LogEventId.ScannerBatchEnded, 'system', {
disposition: 'success',
message: 'Current scanning batch finished on polls closed.',
batchId: ongoingBatchId,
});
}
const ballotsCounted = store.getBallotsCounted();
if (ballotsCounted > 0) {
const exportResult = await exportCastVoteRecordsToUsbDrive({
mode: 'polls_closing',
workspace,
usbDrive,
logger,
});
exportResult.assertOk(
'Failed to finish cast vote record export to USB drive.'
);
}
}

Today, we set the polls store state to closed first, then mark the CVR export as complete. If the latter fails, you run the risk of the export being left in a bad state, with your only course of corrective action being a slow full re-export. By switching the order of operations, you'd be able to correct things by just trying to close polls again, a much faster operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant