Skip to content
Snippets Groups Projects
Commit eceec3b0 authored by Mikhail Karnevskiy's avatar Mikhail Karnevskiy
Browse files

Try to crate/get auto_id again in case of problem. This does happen when...

Try to crate/get auto_id again in case of problem. This does happen when several receivers create new collection.
parent 6c4033ef
Branches
Tags
No related merge requests found
......@@ -366,6 +366,15 @@ Error MongoDBClient::GetNextId(const std::string& stream, uint64_t* id) const {
mongoc_find_and_modify_flags_t(MONGOC_FIND_AND_MODIFY_UPSERT | MONGOC_FIND_AND_MODIFY_RETURN_NEW));
success = mongoc_collection_find_and_modify_with_opts (
collection, &query, opts, &reply, &error);
// E11000 duplicate key error collection
// This does happen when several receivers create new collection
// Just try again
if (!success && error.code == 11000){
success = mongoc_collection_find_and_modify_with_opts (
collection, &query, opts, &reply, &error);
}
Error err;
if (success) {
bson_iter_t iter;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment