[BUG] 邀请 user to group 在成员已承诺后返回 500 个—— CreateGroupChatConversation 中检查时插入的种族

作者: leooooy创建于 2026年8月14日更新于 2026年8月14日
标签bug
  • CreateGroupChatConversation in pkg/common/storage/controller/conversation.go is a check-then-insert:
go
existConversationUserIDs, err := c.conversationDB.FindUserID(ctx, userIDs, []string{conversationID}) // ① read
notExistUserIDs := stringutil.DifferenceString(userIDs, existConversationUserIDs)                    // ② diff
err = c.conversationDB.Create(ctx, conversations)                                                    // ③ insert
  • Create in pkg/common/storage/database/mgo/conversation.go is a plain
go
return mongoutil.InsertMany(ctx, c.coll, conversations)

with no upsert, no $setOnInsert, and no mongo.IsDuplicateKeyError handling. Between ① and ③ there is a window. When a concurrent path creates the same conversation document in that window, both sides see "does not exist" and both insert; the

内容来源: openimsdk/open-im-server