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

[BUG] get_sorted_conversation_list error:1004 mongo find one: mongo: no documents in result mongo #221

Open
marlonyao opened this issue Jan 21, 2025 · 8 comments

Comments

@marlonyao
Copy link

OpenIM Server Version

3.8.2

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Docker Deployment

Bug Description and Steps to Reproduce

我是将 openim 2.3.3 版本迁移到 3.8.2 版本,通过 API 导入了用户(/user/user_register),好友关系(/friend/import_friend),群组(/group/create_group)、聊天记录(/msg/send_msg)。

对于部分用户,当我调用 http://im-server-ip:10002/conversation/get_sorted_conversation_list 接口会报错:

POST http://im-server-ip:10002/conversation/get_sorted_conversation_list
{
  "userID": "some_use_id",
  "pagination": {
    "pageNumber": 1,
    "showNumber": 1000
  }
}

{
    "errCode": 1004,
    "errMsg": "1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result",
    "errDlt": "1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result"
}

有些用户会成功,但是不少用户会失败。服务端报错:

2025-01-21 03:39:11.439	ERROR	[PID:1874]     	openim-rpc-conversation  	[main]                        	[mw/rpc_client_interceptor.go:58]                 	RPC Client Response Error - GetMsgByConversationIDs	{"platform": "Admin", "operationID": "1646445464564", "opUserID": "imAdmin", "funcName": "/openim.msg.msg/GetMsgByConversationIDs", "error": "rpc error: code = Code(1004) desc = mongo find one: mongo: no documents in result"}
2025-01-21 03:39:11.439	WARN	[PID:1874]     	openim-rpc-conversation  	[main]                        	[mw/rpc_server_interceptor.go:94]                 	rpc server resp WithDetails error                 	{"platform": "Admin", "operationID": "1646445464564", "opUserID": "imAdmin", "funcName": "/openim.conversation.conversation/GetSortedConversationList", "error": "Error: 1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result | Error trace: 1 (/go/pkg/mod/google.golang.org/[email protected]/server.go:1029) -> handleStream (/go/pkg/mod/google.golang.org/[email protected]/server.go:1805) -> processUnaryRPC (/go/pkg/mod/google.golang.org/[email protected]/server.go:1394) -> _Conversation_GetSortedConversationList_Handler (/go/pkg/mod/github.com/openimsdk/[email protected]/conversation/conversation_grpc.pb.go:488) -> func1 (/go/pkg/mod/google.golang.org/[email protected]/server.go:1202) -> RpcServerInterceptor (/go/pkg/mod/github.com/openimsdk/[email protected]/mw/rpc_server_interceptor.go:50) -> func1 (/go/pkg/mod/google.golang.org/[email protected]/server.go:1211) -> func4 (/openim-server/pkg/common/startrpc/start.go:193) -> func1 (/go/pkg/mod/github.com/openimsdk/[email protected]/conversation/conversation_grpc.pb.go:486) -> GetSortedConversationList (/openim-server/internal/rpc/conversation/conversation.go:134) -> GetMsgByConversationIDs (/openim-server/pkg/rpcclient/msg.go:205) -> GetMsgByConversationIDs (/go/pkg/mod/github.com/openimsdk/[email protected]/msg/msg_grpc.pb.go:164) -> Invoke (/go/pkg/mod/google.golang.org/[email protected]/call.go:35) -> RpcClientInterceptor (/go/pkg/mod/github.com/openimsdk/[email protected]/mw/rpc_client_interceptor.go:72) -> Wrap (/go/pkg/mod/github.com/openimsdk/[email protected]/errs/coderr.go:74) -> Wrap (/go/pkg/mod/github.com/openimsdk/[email protected]/errs/coderr.go:126)"}
2025-01-21 03:39:11.439	WARN	[PID:1874]     	openim-rpc-conversation  	[main]                        	[mw/rpc_server_interceptor.go:113]                	RPC Server Response Error - GetSortedConversationList	{"platform": "Admin", "operationID": "1646445464564", "opUserID": "imAdmin", "funcName": "/openim.conversation.conversation/GetSortedConversationList", "req": "userID:\"lookcap_u67a160cdb9be451\"  pagination:{pageNumber:1  showNumber:1000}", "err": null, "error": "rpc error: code = Code(1004) desc = 1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result"}
2025-01-21 03:39:11.439	ERROR	[PID:1889]     	openim-api               	[main]                        	[mw/rpc_client_interceptor.go:58]                 	RPC Client Response Error - GetSortedConversationList	{"platform": "Admin", "operationID": "1646445464564", "opUserID": "imAdmin", "funcName": "/openim.conversation.conversation/GetSortedConversationList", "error": "rpc error: code = Code(1004) desc = 1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result"}

我选取了部分详细日志在附件里。
test.log

对于报错的用户,调用 /conversation/get_owner_conversation 和 /conversation/get_all_conversations 接口是没有问题的。我自己看了下数据,可能原因是用户的有些会话,在 msg 集合没有对应记录。

例如:/conversation/get_owner_conversation 返回的其中一个会话 id 为 sg_1909233676,从 `conversation` 集合里也确实能找得到。
但是在 `msg` 里找 {doc_id: 'sg_1909233676:0'} 相关文档,结果为空。 

我不清楚为什么在 msg 没有对应的记录,大部分会话在加好友或者建群时会自动发一条消息,这时会自动创建了 msg 文档。在迁移过程中,我都是调用的相关接口,并没有直接操作数据库。怀疑 openim 在处理建群时存在 bug,数据不一致,但是不一致的概率有点高。

Screenshots Link

No response

@OpenIM-Robot
Copy link

Hello! Thank you for filing an issue.

If this is a bug report, please include relevant logs to help us debug the problem.

Join slack 🤖 to connect and communicate with our developers.

@marlonyao
Copy link
Author

在同步消息时,会有部分报错:

INFO:__main__:url: http://172.27.128.232:10002/msg/send_msg, request: {'sendID': 'lookcap_u35788db25fe1b4f', 'recvID': '', 'groupID': '1464059722', 'senderNickname': '魏嘉', 'senderFaceURL': '', 'senderPlatformID': 5, 'content': {'content': 'https://baike-h5.ilookcap.com/#/pages/detail/detail?id=26424'}, 'contentType': 101, 'sessionType': 3, 'sendTime': 1670574048364, 'ex': '{"v2_server_msg_id": "6e27a5626fd7ce0fb058ef3e4d43f8dc", "v2_client_msg_id": "801645cfb74fc3c00e481f200a79be3e"}'}, response: {"errCode":1004,"errMsg":"1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result","errDlt":"1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result"}
WARNING:__main__:Failed to send chat log: ImV2ChatLog(id=1470, server_msg_id=6e27a5626fd7ce0fb058ef3e4d43f8dc, client_msg_id=801645cfb74fc3c00e481f200a79be3e, send_id=u35788db25fe1b4f, recv_id=1464059722, sender_platform_id=5, sender_nick_name=魏嘉, sender_face_url=https://media.ilookcap.com/avatar/202211/u35788db25fe1b4f1667960076539.png, session_type=2, content_type=101, content=https://baike-h5.ilookcap.com/#/pages/detail/detail?id=26424, status=1, send_time=2022-12-09 16:20:48.364000, create_time=2022-12-09 16:20:48.670000, ex=)
Traceback (most recent call last):
  File "/Users/yaolei/projects/im_migrate/src/im_migrate/migrate.py", line 658, in migrate_chat_log
    v3_send_result = self.im_v3_chat_log_service.send_msg(v3_send_msg)
  File "/Users/yaolei/projects/im_migrate/src/im_migrate/migrate.py", line 485, in send_msg
    data = self.open_im_api_client.send_post('/msg/send_msg', asdict(msg))
  File "/Users/yaolei/projects/im_migrate/src/im_migrate/migrate.py", line 367, in send_post
    return self._send_post(url, data, { 'operationID': self.create_operation_id(), 'token': self._get_admin_token() })
  File "/Users/yaolei/projects/im_migrate/src/im_migrate/migrate.py", line 380, in _send_post
    raise OpenImV3Error(response_data['errCode'], response_data['errMsg'], response_data.get('errDlt'))
OpenImV3Error: OpenImV3Error(code=1004, msg=1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result, detail=1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result)
INFO:__main__:Start migrating chat log: ImV2ChatLog(id=1471, server_msg_id=293f9a87886e99016dd10cacfb2df8b4, client_msg_id=12aa1691a7616968020f4bf16b820f97, send_id=u35788db25fe1b4f, recv_id=1464059722, sender_platform_id=5, sender_nick_name=魏嘉, sender_face_url=https://media.ilookcap.com/avatar/202211/u35788db25fe1b4f1667960076539.png, session_type=2, content_type=114, content={"text":"链接","quoteMessage":{"clientMsgID":"801645cfb74fc3c00e481f200a79be3e","serverMsgID":"6e27a5626fd7ce0fb058ef3e4d43f8dc","createTime":1670574048670,"sendTime":1670574048364,"sessionType":2,"sendID":"u35788db25fe1b4f","msgFrom":100,"contentType":101,"platformID":5,"senderNickname":"魏嘉","senderFaceUrl":"https://media.ilookcap.com/avatar/202211/u35788db25fe1b4f1667960076539.png","groupID":"1464059722","content":"https://baike-h5.ilookcap.com/#/pages/detail/detail?id=26424","seq":0,"isRead":false,"status":2,"offlinePush":{},"attachedInfo":"{\"groupHasReadInfo\":{\"hasReadCount\":0,\"groupMemberCount\":5},\"isPrivateChat\":false,\"hasReadTime\":0,\"notSenderNotificationPush\":false,\"isEncryption\":false,\"inEncryptStatus\":false}","pictureElem":{"sourcePicture":{"size":0,"width":0,"height":0},"bigPicture":{"size":0,"width":0,"height":0},"snapshotPicture":{"size":0,"width":0,"height":0}},"soundElem":{"dataSize":0,"duration":0},"videoElem":{"videoSize":0,"duration":0,"snapshotSize":0,"snapshotWidth":0,"snapshotHeight":0},"fileElem":{"fileSize":0},"mergeElem":{},"atElem":{"isAtSelf":false},"faceElem":{"index":0},"locationElem":{"longitude":0,"latitude":0},"customElem":{},"quoteElem":{},"notificationElem":{},"messageEntityElem":{},"attachedInfoElem":{"groupHasReadInfo":{"hasReadCount":0,"groupMemberCount":5},"isPrivateChat":false,"hasReadTime":0,"notSenderNotificationPush":false,"isEncryption":false,"inEncryptStatus":false}}}, status=1, send_time=2022-12-09 16:21:00.775000, create_time=2022-12-09 16:21:01.080000, ex=)
INFO:__main__:url: http://172.27.128.232:10002/user/get_users_info, request: {'userIDs': ['lookcap_u35788db25fe1b4f']}, response: {"errCode":0,"errMsg":"","errDlt":"","data":{"usersInfo":[{"userID":"lookcap_u35788db25fe1b4f","nickname":"魏嘉","faceURL":"","ex":"{\"ginkgoUserId\":1064,\"userType\":1,\"tenant\":\"lookcap\",\"ginkgoMemberId\":1364}","createTime":1736989893968,"appMangerLevel":0,"globalRecvMsgOpt":0}]}}
INFO:__main__:url: http://172.27.128.232:10002/msg/send_msg, request: {'sendID': 'lookcap_u35788db25fe1b4f', 'recvID': '', 'groupID': '1464059722', 'senderNickname': '魏嘉', 'senderFaceURL': '', 'senderPlatformID': 5, 'content': {'content': '链接'}, 'contentType': 101, 'sessionType': 3, 'sendTime': 1670574060775, 'ex': '{"v2_server_msg_id": "293f9a87886e99016dd10cacfb2df8b4", "v2_client_msg_id": "12aa1691a7616968020f4bf16b820f97"}'}, response: {"errCode":1004,"errMsg":"1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result","errDlt":"1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result"}
WARNING:__main__:Failed to send chat log: ImV2ChatLog(id=1471, server_msg_id=293f9a87886e99016dd10cacfb2df8b4, client_msg_id=12aa1691a7616968020f4bf16b820f97, send_id=u35788db25fe1b4f, recv_id=1464059722, sender_platform_id=5, sender_nick_name=魏嘉, sender_face_url=https://media.ilookcap.com/avatar/202211/u35788db25fe1b4f1667960076539.png, session_type=2, content_type=114, content={"text":"链接","quoteMessage":{"clientMsgID":"801645cfb74fc3c00e481f200a79be3e","serverMsgID":"6e27a5626fd7ce0fb058ef3e4d43f8dc","createTime":1670574048670,"sendTime":1670574048364,"sessionType":2,"sendID":"u35788db25fe1b4f","msgFrom":100,"contentType":101,"platformID":5,"senderNickname":"魏嘉","senderFaceUrl":"https://media.ilookcap.com/avatar/202211/u35788db25fe1b4f1667960076539.png","groupID":"1464059722","content":"https://baike-h5.ilookcap.com/#/pages/detail/detail?id=26424","seq":0,"isRead":false,"status":2,"offlinePush":{},"attachedInfo":"{\"groupHasReadInfo\":{\"hasReadCount\":0,\"groupMemberCount\":5},\"isPrivateChat\":false,\"hasReadTime\":0,\"notSenderNotificationPush\":false,\"isEncryption\":false,\"inEncryptStatus\":false}","pictureElem":{"sourcePicture":{"size":0,"width":0,"height":0},"bigPicture":{"size":0,"width":0,"height":0},"snapshotPicture":{"size":0,"width":0,"height":0}},"soundElem":{"dataSize":0,"duration":0},"videoElem":{"videoSize":0,"duration":0,"snapshotSize":0,"snapshotWidth":0,"snapshotHeight":0},"fileElem":{"fileSize":0},"mergeElem":{},"atElem":{"isAtSelf":false},"faceElem":{"index":0},"locationElem":{"longitude":0,"latitude":0},"customElem":{},"quoteElem":{},"notificationElem":{},"messageEntityElem":{},"attachedInfoElem":{"groupHasReadInfo":{"hasReadCount":0,"groupMemberCount":5},"isPrivateChat":false,"hasReadTime":0,"notSenderNotificationPush":false,"isEncryption":false,"inEncryptStatus":false}}}, status=1, send_time=2022-12-09 16:21:00.775000, create_time=2022-12-09 16:21:01.080000, ex=)
Traceback (most recent call last):
  File "/Users/yaolei/projects/im_migrate/src/im_migrate/migrate.py", line 658, in migrate_chat_log
    v3_send_result = self.im_v3_chat_log_service.send_msg(v3_send_msg)
  File "/Users/yaolei/projects/im_migrate/src/im_migrate/migrate.py", line 485, in send_msg
    data = self.open_im_api_client.send_post('/msg/send_msg', asdict(msg))
  File "/Users/yaolei/projects/im_migrate/src/im_migrate/migrate.py", line 367, in send_post
    return self._send_post(url, data, { 'operationID': self.create_operation_id(), 'token': self._get_admin_token() })
  File "/Users/yaolei/projects/im_migrate/src/im_migrate/migrate.py", line 380, in _send_post
    raise OpenImV3Error(response_data['errCode'], response_data['errMsg'], response_data.get('errDlt'))
OpenImV3Error: OpenImV3Error(code=1004, msg=1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result, detail=1004 mongo find one: mongo: no documents in result mongo find one: mongo: no documents in result)

@marlonyao
Copy link
Author

同步下最新进展:我将数据删除了重新再刷,就好了。

这次刷的时候,改了一下迁移脚本,在调用 openim 接口之前增加了更多校验,例如创建群时,会校验群成员是否是一个有效的 user,给群发消息时,校验群是否已经解散了,解散了就不迁移。每迁移一个步骤,都校验一下 conversation 和 msg 数据是否一致。这样 send_msg 接口报 mongo find one: mongo: no documents in result mongo 的错误就少多了。

这次迁移和上次迁移还有一个步骤不一样,最开始迁移的时候多添加了一些好友,后面又人为删掉了一些好友(调用 delete_friend 接口),不清楚这会不会导致 msg 和 collection 数据不一致。

@OpenIM-Robot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The latest progress in synchronization: I deleted the data and refreshed it again, and it was fine.

When refreshing this time, I changed the migration script and added more verifications before calling the openim interface. For example, when creating a group, it will be verified whether the group member is a valid user, and when sending a message to the group, it will be verified whether the group is a valid user. It has been disbanded. Once disbanded, it will not be moved. At each migration step, check whether the conversation and msg data are consistent. In this way, the send_msg interface reports mongo find one: mongo: no documents in result mongo errors much less.

There is another step that is different between this migration and the last migration. At the beginning of the migration, some more friends were added, and later some friends were manually deleted (the delete_friend interface was called). It is not clear whether this will cause msg and collection data to be lost. Inconsistent.

@marlonyao
Copy link
Author

update: 这个问题又出现了!!

我昨天迁移的数据,刚迁移时没有问题,也没做什么操作,部分用户 get_sorted_conversation_list 接口会报错。不清楚什么原因了。

@OpenIM-Robot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


update: This problem has appeared again! !

The data I migrated yesterday had no problems when it was first migrated, and no operations were performed. Some users will report an error in the get_sorted_conversation_list interface. Not sure why.

@icey-yu
Copy link
Member

icey-yu commented Feb 14, 2025

Is it still caused by the inconsistency between the data in the msg table and the conversation data?

@skiffer-git skiffer-git changed the title [BUG] get_sorted_conversation_list 接口报错:1004 mongo find one: mongo: no documents in result mongo [BUG] get_sorted_conversation_list error:1004 mongo find one: mongo: no documents in result mongo Feb 24, 2025
@skiffer-git
Copy link
Member

We’ve reviewed your log, and it seems a bit complicated.
We suggest you clearly outline the entire process so that we can assist you in resolving this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants