diff --git a/integration/commands_administration_test.go b/integration/commands_administration_test.go index c9abfa976d08..38d7f3e3b875 100644 --- a/integration/commands_administration_test.go +++ b/integration/commands_administration_test.go @@ -1202,10 +1202,8 @@ func TestCommandsAdministrationKillCursors(t *testing.T) { AssertEqualDocuments(t, expected, actual) }) - t.Run("WrongType", func(tt *testing.T) { - tt.Parallel() - - t := setup.FailsForFerretDB(tt, "https://github.com/FerretDB/FerretDB/issues/1514") + t.Run("WrongType", func(t *testing.T) { + t.Parallel() c, err := collection.Find(ctx, bson.D{}, options.Find().SetBatchSize(1)) require.NoError(t, err) @@ -1215,12 +1213,12 @@ func TestCommandsAdministrationKillCursors(t *testing.T) { var actual bson.D err = collection.Database().RunCommand(ctx, bson.D{ {"killCursors", collection.Name()}, - {"cursors", bson.A{c.ID(), "foo"}}, + {"cursors", bson.A{c.ID(), int32(100500)}}, }).Decode(&actual) expectedErr := mongo.CommandError{ Code: 14, Name: "TypeMismatch", - Message: "BSON field 'killCursors.cursors.1' is the wrong type 'string', expected type 'long'", + Message: "BSON field 'killCursors.cursors.1' is the wrong type 'int', expected type 'long'", } AssertEqualCommandError(t, expectedErr, err) diff --git a/internal/handlers/common/killcursors.go b/internal/handlers/common/killcursors.go index 76662bb4415a..fd04870c7059 100644 --- a/internal/handlers/common/killcursors.go +++ b/internal/handlers/common/killcursors.go @@ -59,6 +59,7 @@ func KillCursors(ctx context.Context, msg *wire.OpMsg, registry *cursor.Registry iter := cursors.Iterator() defer iter.Close() + var ids []int64 cursorsKilled := types.MakeArray(0) cursorsNotFound := types.MakeArray(0) cursorsAlive := types.MakeArray(0) @@ -87,6 +88,10 @@ func KillCursors(ctx context.Context, msg *wire.OpMsg, registry *cursor.Registry ) } + ids = append(ids, id) + } + + for _, id := range ids { cursor := registry.Get(id) if cursor == nil || cursor.DB != db || cursor.Collection != collection || cursor.Username != username { cursorsNotFound.Append(id)