Modify conversation_id index options#3722
Open
buvidk1234 wants to merge 2 commits into
Open
Conversation
Removed the unique constraint from the conversation_id index.
…lient timeout Root cause: Due to browser API restrictions, Web (Wasm) clients cannot actively send standard WebSocket Ping frames. They rely entirely on server-initiated Pings (every 27s) and automatic browser Pong responses to maintain the connection. The `pongHandler` was empty and failed to reset the connection's read deadline upon receiving a Pong, causing the server's read loop to strictly time out at 30 seconds. Solution: Call `c.setReadDeadline()` inside the `pongHandler` to properly extend the connection's lifespan when a Pong frame is received.
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.
1. Modify conversation_id index options
Removed the unique constraint from the conversation_id index.
📝 Description
This PR fixes a critical regression introduced in #3668, where a global
uniqueconstraint was incorrectly added to the standaloneconversation_idindex in MongoDB.Root Cause:
In OpenIM's architecture, a single conversation (e.g., a Single Chat or Group Chat) is shared among multiple users. Therefore, multiple documents in the
conversationcollection will naturally share the sameconversation_idbut have differentowner_user_ids.The unique constraint introduced in #3668 prevented the system from creating conversation records for the receiving user, throwing an
E11000 duplicate key error.Chain Reaction & Symptoms Fixed:
nullor missing data during sync. This directly causes the frontend JS/Wasm SDK to crash with:[getAllConversationList] errCode: 10006, errMsg: Cannot convert undefined or null to object.The Fix:
Removed
.SetUnique(true)from theconversation_idindex.conversation_idis kept as a normal index to preventCOLLSCAN(Out of Memory/Timeout issues like those in v3.8.3).(owner_user_id, conversation_id).For environments that have already run the faulty code, the
conversation_id_1index must be manually dropped from MongoDB (db.conversation.dropIndex("conversation_id_1")) before restarting the server, as the code change alone will not alter an existing MongoDB index's unique property.🅰 Please add the issue ID after "Fixes #"
Fixes #3691 #3692 #3693 #3700 #3708
2. fix(msggateway): reset read deadline in pong handler to prevent Web client timeout
Root cause:
Due to browser API restrictions, Web (Wasm) clients cannot actively send standard WebSocket Ping frames. They rely entirely on server-initiated Pings (every 27s) and automatic browser Pong responses to maintain the connection. The
pongHandlerwas empty and failed to reset the connection's read deadline upon receiving a Pong, causing the server's read loop to strictly time out at 30 seconds.Solution:
Call
c.setReadDeadline()inside thepongHandlerto properly extend the connection's lifespan when a Pong frame is received.