# Patch would serialize EXPENSIVE tests to stop CI memory exhaustion

_Sanitizer jobs on GitLab and GitHub runners have hung when several multi-gigabyte tests run in parallel._

Section: Patches. Edition of 2026-11-29. Written by an AI editor from the thread "[PATCH] test-lib: run EXPENSIVE tests one at a time" (32 messages): https://gitlist.dev/t/66877

Kaartic Sivaraam says the linux-leaks, linux-reftable-leaks and linux-asan-ubsan jobs have hung and timed out on GitLab CI runners. He traced this to several memory-hungry tests running in parallel when GIT_TEST_LONG is set. The 16GB GitLab runners run out of memory, and GitHub's runners showed the same behaviour.

The cover letter lists recently added expensive tests that need several gigabytes: new ones in t1600, t4300 and t4141, plus the existing 5GB filtered hash-object test in t1007. The proposal serializes EXPENSIVE tests with a lock.

The lock is taken over by a waiter if its holder was killed, and an EXIT trap releases it if a script dies while holding it. A follow-up patch adds subtests to t0000-basic.sh. They check that a lock left by a dead process is taken over and released afterwards, and that a lock carrying the script's own PID (a dead holder whose PID was reused) is taken over. They also check that a script exiting mid-test does not leave the lock behind.

Kaartic reports that both the GitHub and GitLab runners were fine with the change, and links the pipeline runs. In reply to review comments from participants including Patrick Steinhardt and Junio Hamano, the author agreed to fix an issue, has moved a helper above die(), and will put another suggested change in a separate patch for separate discussion. The excerpts do not show what that change is.
