/dev/stdin will not always pipe / work in all environments#2195
Open
Adel-Magebinary wants to merge 1 commit into
Open
/dev/stdin will not always pipe / work in all environments#2195Adel-Magebinary wants to merge 1 commit into
Adel-Magebinary wants to merge 1 commit into
Conversation
Incident Report: Galera SST Failures in Some Docker Environment 1. Issue Description Galera State Snapshot Transfer (SST) scripts (specifically wsrep_sst_common and its derivatives) were hanging or failing during the joiner-side post-processing phase. The failures occurred primarily during temporary mysqld startup and internal credential validation via mysqladmin. 2. Root Cause Analysis The issue was traced to a fundamental filesystem namespace limitation in the Triton (SmartOS/LX-brand) container environment regarding file descriptor mapping. Technical Breakdown: Broken Symlinks: The standard /dev/stdin path in Triton is often a relative symlink pointing to ../proc/self/fd/0. This resolution fails inside many containerized shells, returning No such file or directory. Restricted Kernel Paths: Direct access to the kernel path /proc/self/fd/0 (standard Linux "magic" for stdin) is restricted or namespaced in the Triton LX-brand zones, preventing binaries from opening it as a regular file. Blocking Named Pipes: Attempting to simulate stdin via mkfifo (Named Pipes) resulted in deadlocks, as FIFOs are blocking by nature and require perfectly synchronized reader/writer processes, which the asynchronous nature of SST scripts does not provide. 3. Resolution The resolution required a "Buffer-to-Disk" architectural change to the shell scripts, moving away from streaming data via pipes to persistent temporary files. Key Changes: Elimination of /dev/stdin: All references to the magic path /dev/stdin were replaced with unique temporary files generated by mktemp. Removal of Process Substitution: Logic using <(command) (which relies on /dev/fd/ mapping) was refactored to write command output to a temp file, read the file, and then delete it. Two-Step Initialization: For the critical mysqld --init-file startup: Original: cat <<EOF | mysqld --init-file=/dev/stdin (Failed due to broken path). Fixed: The SQL commands are written to /tmp/sst_init.XXXXXX first, and mysqld is pointed to the absolute path of this regular file. Credential Buffering: Authentication details are now dumped into a disk-backed .cnf file in /tmp for the duration of the SST process, ensuring mysqladmin and mysql clients have a reliable path to access credentials. 4. Verification Results Test 1 (Standard Redirection): FAILED (Confirmed /dev/stdin unreachable). Test 2 (Direct FD Path): FAILED (Confirmed /proc/self/fd/0 unreachable). Test 3 (Regular File Buffer): SUCCESS (Confirmed reliable execution). 5. Implementation Notes The updated wsrep_sst_common script now utilizes the mktemp utility to ensure unique file names and implements immediate cleanup (rm -f) to ensure no sensitive credential data persists in /tmp after the transfer is complete.
kamil-holubicki
self-requested a review
December 19, 2025 21:48
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.
Incident Report: Galera SST Failures in Some Docker Environment
Galera State Snapshot Transfer (SST) scripts (specifically wsrep_sst_common and its derivatives) were hanging or failing during the joiner-side post-processing phase. The failures occurred primarily during temporary mysqld startup and internal credential validation via mysqladmin.
The issue was traced to a fundamental filesystem namespace limitation in the Triton (SmartOS/LX-brand) container environment regarding file descriptor mapping.
Technical Breakdown:
Broken Symlinks: The standard /dev/stdin path in Triton is often a relative symlink pointing to ../proc/self/fd/0. This resolution fails inside many containerized shells, returning No such file or directory.
Restricted Kernel Paths: Direct access to the kernel path /proc/self/fd/0 (standard Linux "magic" for stdin) is restricted or namespaced in the Triton LX-brand zones, preventing binaries from opening it as a regular file.
Blocking Named Pipes: Attempting to simulate stdin via mkfifo (Named Pipes) resulted in deadlocks, as FIFOs are blocking by nature and require perfectly synchronized reader/writer processes, which the asynchronous nature of SST scripts does not provide.
The resolution required a "Buffer-to-Disk" architectural change to the shell scripts, moving away from streaming data via pipes to persistent temporary files.
Key Changes:
Elimination of /dev/stdin: All references to the magic path /dev/stdin were replaced with unique temporary files generated by mktemp.
Removal of Process Substitution: Logic using <(command) (which relies on /dev/fd/ mapping) was refactored to write command output to a temp file, read the file, and then delete it.
Two-Step Initialization: For the critical mysqld --init-file startup:
Original: cat <<EOF | mysqld --init-file=/dev/stdin (Failed due to broken path).
Fixed: The SQL commands are written to /tmp/sst_init.XXXXXX first, and mysqld is pointed to the absolute path of this regular file.
Credential Buffering: Authentication details are now dumped into a disk-backed .cnf file in /tmp for the duration of the SST process, ensuring mysqladmin and mysql clients have a reliable path to access credentials.
Test 1 (Standard Redirection): FAILED (Confirmed /dev/stdin unreachable).
Test 2 (Direct FD Path): FAILED (Confirmed /proc/self/fd/0 unreachable).
Test 3 (Regular File Buffer): SUCCESS (Confirmed reliable execution).
The updated wsrep_sst_common script now utilizes the mktemp utility to ensure unique file names and implements immediate cleanup (rm -f) to ensure no sensitive credential data persists in /tmp after the transfer is complete.