Skip to content

Concurrent /checkin requests can create duplicate log posts and lose progress #107

Open

Description

@piyusshhjangid

Bug

recordCheckin reads the member's KV record, validates the daily limit, posts to Discord, and only then writes the updated record. There is no per-user/roadmap serialization or atomic claim around that sequence.

If two /checkin interactions for the same member and roadmap run concurrently, both can read the same previous record and both pass applyCheckin. Both then post a check-in, while the last KV write wins. On a first check-in, this can create two forum log threads and leave one unreferenced; on an existing log, it can post the same day twice while incrementing checkins only once.

Reproduction

  1. Start two /checkin interactions at nearly the same time for the same user and roadmap (for example, with Promise.all against an empty test KV state and the same now).
  2. Both executions can read null before either writes the record.
  3. Observe that both return success and both post to Discord, although only one record is stored.

Expected behavior

At most one concurrent request should record and post a check-in for a user and roadmap on a given day. The other should report that today's check-in is already recorded, without creating another post or thread.

Activity

  1. piyusshhjangid commented on Oct 29, 2026

    @piyusshhjangid
    ContributorAuthor

    hey @anurag629, could you assign this to me once codercops/ogcops#303 gets merged? Also, could you add the Hacktoberfest label to it?

  2. anurag629 commented on Oct 29, 2026

    @anurag629
    Member

    Hey @piyusshhjangid, fair catch: two /checkin calls close together can both read the old record before either one writes. KV has no compare-and-swap, so it can't be fully atomic, but writing the day's record before posting (and putting the old one back if the post fails) shrinks the window from the Discord round trips to a few milliseconds, which is enough here. It's yours once codercops/ogcops#303 is merged, just say so here then.

  3. added
    bugSomething isn't working
    hacktoberfestGood pick for Hacktoberfest contributors
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghacktoberfestGood pick for Hacktoberfest contributors

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions