Need help understanding the mutations and OCC
I'm working on a million checkboxes type of clone, and I have a function called toggleCheckbox which will first query a record, toggle a bit on or off in the number, and then write that number. This all seems to work fine. I'm also using another metadata table to keep a running sum of how many checkboxes are on or off. It seems like the counts are getting off for some reason.
I created a cron which randomly toggles a bit using that same method described above every second in the first set of checkboxes. That also seems to work fine. The issue is when I manually start clicking checkboxes while the cron is running that my count seems to get off. I think there is something I'm not understanding about the concurrency model.
3 Replies
here is some code for context
all the UI does is call
updateCheckbox({
index: index % BITS,
partition: partitionIndex,
});
when a checkbox is clicked, so the mutation should be able to figure out the final state of the box
just found the issue 😆
const index = Math.floor(Math.random() * 31); // need to use 31 not 32
have you seen https://github.com/atrakh/one-million-checkboxes/tree/main/convex
hosted at https://labs.convex.dev/million ?
GitHub
one-million-checkboxes/convex at main · atrakh/one-million-checkboxes
https://onemillioncheckboxes.com/ recreated with Convex - atrakh/one-million-checkboxes
yeah, am using that as a reference a bit
but doing my own approach