Add Sidekiq middleware to inspect the state of Thread.current

We saw that in https://gitlab.com/gitlab-org/gitlab-ce/issues/53079, Thread.current had some state that wasn't cleared between Sidekiq jobs, leading to some incorrectly cached values.

As @DouweM mentions in https://gitlab.com/gitlab-org/gitlab-ce/issues/53079#note_119456981:

We could implement that using a Sidekiq middleware wrapping all others, that would log a message somewhere if anything unexpected shows up in Thread.current.

Edited Oct 20, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading