Skip to content

Commit a0e6d9a

Browse files
authored
fix: Mongo Malloc upsert overwrites min_seq initialization (#3657)
* fix: performance issues with Kafka caused by encapsulating the MQ interface * fix: admin token in standalone mode * fix: full id version * fix: resolve deadlock in cache eviction and improve GetBatch implementation * refactor: replace LongConn with ClientConn interface and simplify message handling * refactor: replace LongConn with ClientConn interface and simplify message handling * fix: seq use $setOnInsert for min_seq in conversation update
1 parent fbca49d commit a0e6d9a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/common/storage/database/mgo/seq_conversation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func (s *seqConversationMongo) Malloc(ctx context.Context, conversationID string
5757
}
5858
filter := map[string]any{"conversation_id": conversationID}
5959
update := map[string]any{
60-
"$inc": map[string]any{"max_seq": size},
61-
"$set": map[string]any{"min_seq": int64(0)},
60+
"$inc": map[string]any{"max_seq": size},
61+
"$setOnInsert": map[string]any{"min_seq": int64(0)},
6262
}
6363
opt := options.FindOneAndUpdate().SetUpsert(true).SetReturnDocument(options.After).SetProjection(map[string]any{"_id": 0, "max_seq": 1})
6464
lastSeq, err := mongoutil.FindOneAndUpdate[int64](ctx, s.coll, filter, update, opt)

0 commit comments

Comments
 (0)