• 
      

    Avoid a crash if a new RegisteredExtension conflicts in the database.

    Review Request #15435 — Created Oct. 28, 2026 and updated

    Information

    Djblets
    release-6.x

    Reviewers

    Whenever a new extension is discovered, a RegisteredExtension is
    created in the database, and if one was created by another process since
    it was checked, the extension manager would try fetching it. However,
    since we're inside a transaction, this could end up aborting it instead
    of doing what we want it to do.

    We now use get_or_create(), which manages this inside a savepoint. It
    does introduce one extra SELECT for each newly-discovered extension,
    but that's going to be a rare event. This is still better than
    attempting to manage transaction logic ourselves.

    Unit tests pass.

    Summary ID
    Avoid a crash if a new RegisteredExtension conflicts in the database.
    Whenever a new extension is discovered, a `RegisteredExtension` is created in the database, and if one was created by another process since it was checked, the extension manager would try fetching it. However, since we're inside a transaction, this could end up aborting it instead of doing what we want it to do. We now use `get_or_create()`, which manages this inside a savepoint. It does introduce one extra `SELECT` for each newly-discovered extension, but that's going to be a rare event. This is still better than attempting to manage transaction logic ourselves.
    e794c2214474b5bb67baae6b0e7d506454bc26fb
    Checks run (2 succeeded)
    flake8 passed.
    JSHint passed.