fix(likes): count unique visitors and sync denormalized counter#96
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(likes): count unique visitors and sync denormalized counter#96cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Parallel setLike races could leave multiple likes rows for one ipHash. Reads used row count (and backfill incremented per row), inflating counts. Dedup decrements could also desync the denormalized counter. Count distinct ipHashes, sync the counter after each mutation, and rebuild backfill totals per URL from unique visitors. Co-authored-by: Injoon Oh <injoon5@icloud.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
Recent denormalized like counts (PR #85) could show inflated or deflated totals when parallel
setLikecalls left duplicatelikesrows for the same visitor, or when dedup deleted extra rows while decrementing a counter that never reflected those rows. One visitor rapid-clicking could move the public count by more than ±1.Root cause
readLikeCount(pre-backfill) and backfill used row count instead of distinctipHashsetLikecalleddecrementLikeCountper removed duplicate, desyncinglikeCountsfrom realityFix
Cherry-pick of
d6e92c1(already validated oncursor/critical-correctness-bugs-605e):uniqueLikeCountsetLike,syncLikeCountForUrlsets the denormalized counter from source rows (also runs on idempotent retries, healing drift)scripts/like-unique-count-test.mjs(12 parallel toggles; global count must move ≤1)Validation
cursor/critical-bug-investigation-bc6dsetLike/readLikeCount/ backfill paths