Fix race condition in concurrent extension media installation.

Review Request #14856 — Created Feb. 26, 2026 and submitted

Information

Djblets
release-5.x

Reviewers

When running tests on CI, I hit a race condition which caused the
ExtensionManagerTests::test_install_media_concurrent_threads test to
fail.

The version check in install_extension_media() happened only before
acquiring the lock file. If one thread completed the install and released
the lock before another thread attempted to acquire it, the second thread
would successfully lock and redundantly reinstall, since its local
old_version was already stale.

This change makes us re-check the installed version after acquiring the
lock to skip the install if another thread/process already completed it.

Ran unit tests.

Summary ID
Fix race condition in concurrent extension media installation.
When running tests on CI, I hit a race condition which caused the `ExtensionManagerTests::test_install_media_concurrent_threads` test to fail. The version check in `install_extension_media()` happened only before acquiring the lock file. If one thread completed the install and released the lock before another thread attempted to acquire it, the second thread would successfully lock and redundantly reinstall, since its local old_version was already stale. This change makes us re-check the installed version after acquiring the lock to skip the install if another thread/process already completed it. Testing Done: Ran unit tests.
sozvymzulnkzsutumprovzkqmpympuwu
Description From Last Updated

Let's put the trailing ) on the next line to match the style we usually use for this case.

chipx86chipx86
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. djblets/extensions/manager.py (Diff revision 1)
     
     
     
     
    Show all issues

    Let's put the trailing ) on the next line to match the style we usually use for this case.

  3. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.2.x (495d49a)