Repository navigation
fix(ddevapp): read db version from a running container via exec, not a second volume mount (#8658) [skip ci] - #8658
Merged
rfay merged 1 commit intoAug 12, 2026
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
…a second volume mount GetExistingDBType() always spun up a utility container mounting the db volume, even when the real db container was already running and holding that same volume. On providers where a volume can only be attached read-write by one container at a time (Apple Container/socktainer, investigated for ddev#7372), that second mount fails outright with a VZ storage-attachment error - so `ddev ssh`, `ddev start` and anything else that calls Start() on an already-running project can never succeed there. It is also needlessly expensive everywhere else: the function's own comment already conceded "this has to make a Docker container run so is fairly costly." When the db container is already running, read its version file directly with an exec instead: cheaper on every provider, and the only way this can succeed at all on providers with exclusive-attach volumes. Falls back to the original volume-mount approach when the container isn't running (nonexistent, exited, etc.), where the volume is idle and mounting it elsewhere is safe - unchanged from today. Extracted the shared shell script (which locations to check for a MySQL/ MariaDB or PostgreSQL version file, in what order) into getDBVersionFromVolumeScript(), parameterized by the three file paths to check, so both the exec-into-the-running-container call and the utility-container call use the same logic. The live paths (/var/lib/mysql, /var/lib/postgresql) come from the same layout documented by GetPostgresDataDir()/GetPostgresDataPath() (see the docker-library/ postgres#1259 comment there for why PostgreSQL 18+ differs from earlier versions). Verified against a real project on OrbStack: the exec path returns the correct type/version in ~650ms while the db container is running, and stopping the container falls back to the (unchanged) volume-mount path with the same result. Added TestGetDBVersionFromVolumeScript as a whitebox test exercising the shared script directly (no Docker needed) for both the MariaDB and PostgreSQL pre-18/18+/future-version cases, plus the precedence and not-found cases. The existing Docker-based integration test of the same name in db_test.go, which duplicates the utility-container script inline against a real container, is unchanged and continues to pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
rfay
force-pushed
the
20260802_rfay_existing_db_type_no_volume_conflict
branch
from
August 8, 2026 15:13
c2403ca to
0ce5dd2
Compare
rfay
marked this pull request as ready for review
August 11, 2026 01:19
rfay
commented
Aug 11, 2026
Member
Author
There was a problem hiding this comment.
I tested this by stepping through ddev ut get-volume-db-version with project stopped or started, and it was fine. I think we have adequate test coverage. I remember a performance issue about this exact idea long ago that I guess didn't end up getting this part completed. I'm not happy to add the extra code, but I am happy with the more appropriate exec path. I think it can go in just fine.
stasadev
approved these changes
Aug 11, 2026
stasadev
left a comment
Member
There was a problem hiding this comment.
Looks good to me.
I'm not sure why we're mounting to /var/tmp with ddev/ddev-utilities instead of using /var/lib everywhere, but that's fine.
I confirm that the check is much faster with a project running.
rfay
added a commit
to rfay/ddev
that referenced
this pull request
Oct 11, 2026
…striction, for ddev#7372 [skip ci] dbVersionFromRunningContainer() never ran: upstream's getDBVersionFromVolume (ddev#8658) already execs into a running db container and returns before reaching it. The networks: ["ddev_default"] restriction on db and web never took effect, because fixupComposeYaml adds the default network back to every service. Routing to a multi-homed web container works through socktainer's DNS answering with the querying network's address instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay
added a commit
to rfay/ddev
that referenced
this pull request
Oct 12, 2026
…striction, for ddev#7372 [skip ci] dbVersionFromRunningContainer() never ran: upstream's getDBVersionFromVolume (ddev#8658) already execs into a running db container and returns before reaching it. The networks: ["ddev_default"] restriction on db and web never took effect, because fixupComposeYaml adds the default network back to every service. Routing to a multi-homed web container works through socktainer's DNS answering with the querying network's address instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay
added a commit
to rfay/ddev
that referenced
this pull request
Oct 20, 2026
…striction, for ddev#7372 [skip ci] dbVersionFromRunningContainer() never ran: upstream's getDBVersionFromVolume (ddev#8658) already execs into a running db container and returns before reaching it. The networks: ["ddev_default"] restriction on db and web never took effect, because fixupComposeYaml adds the default network back to every service. Routing to a multi-homed web container works through socktainer's DNS answering with the querying network's address instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay
added a commit
to rfay/ddev
that referenced
this pull request
Oct 21, 2026
…striction, for ddev#7372 [skip ci] dbVersionFromRunningContainer() never ran: upstream's getDBVersionFromVolume (ddev#8658) already execs into a running db container and returns before reaching it. The networks: ["ddev_default"] restriction on db and web never took effect, because fixupComposeYaml adds the default network back to every service. Routing to a multi-homed web container works through socktainer's DNS answering with the querying network's address instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay
added a commit
to rfay/ddev
that referenced
this pull request
Oct 27, 2026
…striction, for ddev#7372 [skip ci] dbVersionFromRunningContainer() never ran: upstream's getDBVersionFromVolume (ddev#8658) already execs into a running db container and returns before reaching it. The networks: ["ddev_default"] restriction on db and web never took effect, because fixupComposeYaml adds the default network back to every service. Routing to a multi-homed web container works through socktainer's DNS answering with the querying network's address instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rfay
added a commit
to rfay/ddev
that referenced
this pull request
Oct 31, 2026
…striction, for ddev#7372 [skip ci] dbVersionFromRunningContainer() never ran: upstream's getDBVersionFromVolume (ddev#8658) already execs into a running db container and returns before reaching it. The networks: ["ddev_default"] restriction on db and web never took effect, because fixupComposeYaml adds the default network back to every service. Routing to a multi-homed web container works through socktainer's DNS answering with the querying network's address instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Issue
GetExistingDBType()determines the running project's db type/version bymounting the db volume into a throwaway utility container and reading a
version file from it. If the real
dbcontainer is already running, thatvolume is already attached read-write, and Apple Container's volume
semantics only allow one read-write attacher (or many read-only) at a
time — so the utility-container mount fails and the command errors out.
This is a genuine DDEV bug: any provider that enforces stricter (and
more standard) volume-exclusivity semantics than a permissive Docker
Engine will hit it, so it isn't Apple-Container-specific in principle,
just newly exposed by it.
How This PR Solves The Issue
When the
dbcontainer is already running,getDBVersionFromVolume()nowexecs directly into it to read the version file instead of mounting the
volume into a separate utility container. The version-detection script is
shared (parameterized by explicit file/glob paths) between this fast path
and the original utility-container fallback used when
dbisn't running,so MariaDB and both pre-18 and 18+ PostgreSQL data layouts are handled the
same way in either case.
Manual Testing Instructions
go test -v ./pkg/ddevapp -run TestGetDBVersionFromVolumeScriptddev start), then run a command that callsGetExistingDBType()(e.g.ddev configagain, orddev describe)while the db container is already running — should succeed instead of
erroring on the volume mount.
Automated Testing Overview
Added
TestGetDBVersionFromVolumeScriptinpkg/ddevapp/db_internal_test.go(whitebox, packageddevapp), coveringMariaDB, pre-18 Postgres, 18+/nested Postgres, precedence between them,
and the not-found case, by running the generated script locally via bash
against a temp directory (no Docker required). The existing
Docker-integration test of the same name in
pkg/ddevapp/db_test.goisunchanged and still passes.
Release/Deployment Notes
None. Pure
pkg/ddevappchange, no image dependency.