In merge_causes_infinite_loop.js, we attempt to expose the Halloween problem with a $merge pipeline that writes to the same collection that is aggregated. The test assumes that this will cause documents to be updated and pushed forward indefinitely, which will cause the computed values to eventually overflow. As such, after writing to the same collection that is aggregated, the test used to have this assertion that it fails with an overflow error.
The error code in the assertion corresponds to this uassert, which $multiply will no longer trip as a result of
SERVER-60588's changes to the implementation. Therefore, I removed the assertion as a part of that ticket, to avoid failures of this test.
In the process, I realized that this assertion has been succeeding not because there was an infinite loop, as the test assumes, but simply because the starting value of $a was high enough to trip an overflow even when only updating once, as expected. Moreover, I realized that even when writing to the same collection that is being aggregated, each document's value of $a was updated only once. Therefore, the Halloween problem does not actually exist for $merge at the moment.
We need to re-evaluate whether we still need this test, and what exactly we want it to be searching for.
- related to
SERVER-42137 Allow aggregation $merge stage to write to a collection that the query also reads from