Skip to content

Commit

Permalink
fix: deletes queues by chunks
Browse files Browse the repository at this point in the history
errors were observed while the housekeeper attempt to clear queues, the biggest doc didnt have the mongo max of 16MB, so the whole query result was the problem.
"queue/queue.go:413","message":"Error removing elements from storage: rrror deleting storage elements: an inserted document is too large"

Signed-off-by: Cézar <[email protected]>
  • Loading branch information
cezar-tech committed Dec 11, 2024
1 parent bfc9903 commit 372689c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions internal/queue/storage/mongo_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,26 @@ func TestGetMongoMessageWithManyIds(t *testing.T) {

func TestRemove(t *testing.T) {
deleteChunkSize = 1
colMock := newMockCollection()
storage := &MongoStorage{
messagesCollection: newMockCollection(),
messagesCollection: colMock,
}

count, err := storage.Remove(context.Background(), "test_queue", "1", "2")
queue := "test_queue"
count, err := storage.Remove(context.Background(), queue, "1", "2")
require.NoError(t, err)
require.Equal(t, int64(2), count)
require.Equal(t, 2, colMock.deleteManyCalls)
require.Equal(t, []interface{}{bson.M{
"queue": queue,
"id": bson.M{
"$in": []string{"1"},
},
},
bson.M{
"queue": queue,
"id": bson.M{
"$in": []string{"2"},
},
}}, colMock.deleteManyArgs)
}

0 comments on commit 372689c

Please sign in to comment.