feat: bookmarks events handler partial recovery#793
Open
aintnostressin wants to merge 1 commit intomainfrom
Open
feat: bookmarks events handler partial recovery#793aintnostressin wants to merge 1 commit intomainfrom
aintnostressin wants to merge 1 commit intomainfrom
Conversation
ok300
reviewed
Apr 4, 2026
Comment on lines
+63
to
67
| let (post_id, author_id) = match Bookmark::get_target_from_graph(&user_id, &bookmark_id).await? | ||
| { | ||
| Some(info) => info, | ||
| None => return Err(EventProcessorError::SkipIndexing), | ||
| }; |
Contributor
There was a problem hiding this comment.
Suggested change
| let (post_id, author_id) = match Bookmark::get_target_from_graph(&user_id, &bookmark_id).await? | |
| { | |
| Some(info) => info, | |
| None => return Err(EventProcessorError::SkipIndexing), | |
| }; | |
| let (post_id, author_id) = Bookmark::get_target_from_graph(&user_id, &bookmark_id) | |
| .await? | |
| .ok_or(EventProcessorError::SkipIndexing)?; |
| None => return Err(EventProcessorError::SkipIndexing), | ||
| }; | ||
|
|
||
| // 2. Guard counter decrement: only decrement if bookmark still exists in Redis index |
Contributor
There was a problem hiding this comment.
The guard is designed to prevent double-decrement on retry, it it only handles the case where both the Redis index removal and the counter decrement succeed before the graph delete failed.
If del_from_index (step 3) succeeds, but the process crashes before UserCounts::decrement runs, then on retry existed_in_index will be false and the counter will never be decremented.
| test.del(&user_kp, &bookmark_path).await?; | ||
|
|
||
| // Verify fully deleted state | ||
| assert!(find_post_bookmark(&user_id, &post_id, &user_id) |
Contributor
There was a problem hiding this comment.
The test conflates the post author and the bookmarker, which means it doesn't cover the case when post author != bookmarker, which is a more realistic scenario. It would be better if the test creates 2 separate users, author_kp and bookmarker_kp.
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.
Prepares bookmark handlers for partial recovery.