fix: gate MariaDBManager.start() on is_running() to prevent double-start errors#12
Open
amitascra wants to merge 1 commit into
Open
fix: gate MariaDBManager.start() on is_running() to prevent double-start errors#12amitascra wants to merge 1 commit into
amitascra wants to merge 1 commit into
Conversation
MariaDBManager.start() was running brew services start / systemctl start unconditionally. When MariaDB is already running (Docker, remote, or a brew service that's already started), this caused a port-conflict crash: Bootstrap failed: 5: Input/output error Error: Failure while executing; `/bin/launchctl bootstrap gui/501 .../homebrew.mxcl.mariadb.plist` exited with 5. Fix: - Add is_running() using a stdlib TCP probe (socket.create_connection) so no new dependencies are introduced (project is zero-dependency). - Gate start() on is_running(): return early if the configured host:port is already accepting connections. Fixes frappe#3
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.
Problem
MariaDBManager.start() unconditionally calls
brew services start(macOS) orsystemctl start mariadb(Linux), even when MariaDB is already running. This causesbench initto fail at step 2 with a port-conflict error when MariaDB is running via Docker, remote host, or an already-started brew service:Bootstrap failed: 5: Input/output error Error: Failure while executing; /bin/launchctl bootstrap gui/501 .../homebrew.mxcl.mariadb.plist exited with 5.
Fixes #3
Solution
host:portvia a stdlib TCP socket (socket.create_connectionwith 1s timeout). Works for local, Docker, and remote MariaDB instances. No new dependencies (project remains zero-dependency).Testing
Added comprehensive unit tests in tests/test_mariadb_manager.py:
Truewhen port is open,Falseon connection refused or timeoutbench.tomlbrew services start(default and versioned) on macOSsystemctl start mariadbon LinuxAll 8 new tests pass. No regressions in existing tests.