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

fix Client failed to withdraw the message #3257

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

adpanru
Copy link

@adpanru adpanru commented Mar 26, 2025

🅰 Please add the issue ID after "Fixes #"

Fixes #3241

Problem Description
Users were unable to revoke messages, with the server returning error code 1004 (RecordNotFoundError) and the message "msg not found".
Investigation Process
Log Analysis:
Message sending and push operations were successful, with normal log records
During revocation attempts, the error "Error: 1004 RecordNotFoundError msg not found" was returned
Data Consistency Verification:
The conversation API query showed that the maximum sequence number (maxSeq) was 399
However, the message attempting to be revoked had a sequence number of 561
This indicated an inconsistency between database state and actually sent messages
Root Cause:
Messages were successfully sent and pushed to online users but failed to be persisted in MongoDB storage
The conversation sequence number records were not properly updated
When attempting to revoke, the system could not find the message record with the corresponding sequence number
Fix Solution
Design Approach
Implement a fault-tolerant mechanism that allows message revocation to proceed under specific conditions, even when the message record cannot be found.
Implementation Details
Modify the RevokeMsg method in internal/rpc/msg/revoke.go:
Instead of immediately returning an error when a message doesn't exist, implement a fallback strategy
Verify that the sequence number is within a reasonable range
Create a temporary message object for revocation notification
Log warnings but allow the operation to continue
Add Helper Function:
Implement getSessionTypeFromConversationID method to infer session type from conversation ID
Identify single chat or group chat types through prefixes (e.g., "sp_", "sg_")

@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 26, 2025
Copy link

github-actions bot commented Mar 26, 2025

🤖 All Contributors have signed the CLA.
The signed information is recorded here
Posted by the CLA Assistant Lite bot.

@adpanru
Copy link
Author

adpanru commented Mar 26, 2025

I have read the CLA Document and I hereby sign the CLA

OpenIM-Robot added a commit to OpenIM-Robot/cla that referenced this pull request Mar 26, 2025
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 26, 2025
@adpanru adpanru changed the title fix Client failed to withdraw the message fix Client failed to withdraw the message#3241 Mar 26, 2025
@adpanru adpanru changed the title fix Client failed to withdraw the message#3241 fix Client failed to withdraw the message Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Client failed to withdraw the message
1 participant