Bulk Write Error

Hi all,

Thank you in advance for replying to this thread.
I’m not sure if I understand it correctly but when invoking a insert_many, it returns an error as following:

2024/08/27 01:35:06.0071: [37809]: DEBUG: cluster: could not read message length, stream probably closed or timed out
2024/08/27 01:35:09.0435: [37814]: DEBUG: cluster: could not read message length, stream probably closed or timed out
2024/08/27 01:35:09.0618: [37798]: DEBUG: cluster: could not read message length, stream probably closed or timed out
2024/08/27 01:35:11.0045: [37819]: DEBUG: cluster: could not read message length, stream probably closed or timed out
2024/08/27 01:35:23.0519: [37795]: DEBUG: cluster: could not read message length, stream probably closed or timed out
2024/08/27 01:35:37.0422: [37822]: DEBUG: cluster: could not read message length, stream probably closed or timed out
2024/08/27 01:35:37.0508: [37823]: DEBUG: cluster: could not read message length, stream probably closed or timed out
2024/08/27 01:35:44.0657: [37799]: DEBUG: cluster: could not read message length, stream probably closed or timed out
2024/08/27 01:35:50.0258: [37794]: DEBUG: cluster: could not read message length, stream probably closed or timed out

Note that the insert_many works perfectly fine when concurrently insert batches of 1,000 elements for 10 iterations (1 element is 1,024 bytes) when under 16 threads. In other words, each thread inserts a batch of 1 MB for 10 times. However, when the thread count is at 16 threads or above, the above error appeared.

Upon debugging, while uncertain, I believe the problem is due to the fact that those operations take a long time to process and may have reached the time-out limit. I’m not sure if this is a common issue but if time-out is the issue, is increasing time-out limit considers best-practice?

Is socketTimeoutMS overridden? The default is 5 minutes. I suggest also checking the server logs for any error information.

Hi Kevin,

Thanks for your insights. After changing socketTimeoutMS (EX below), the program ended without error.

mongocxx::uri uri("mongodb://127.0.0.1:27017/?socketTimeoutMS=6000000");

I believe the error stems from the fact that the insert call takes a very long time to return and exceeded the time-out limit.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.