• Vladislav Vaintroub's avatar
    MDEV-34546 Windows - no error log entries after startup in XAMPP · 9fdc0e54
    Vladislav Vaintroub authored
    The server does not log errors after startup when it is started without the
    --console parameter and not as a service. This issue arises due to an
    undocumented behavior of FreeConsole() in Windows when only a single
    process (mariadbd/mysqld) is attached to it, causing the window to close.
    
    In this case stderr is redirected to a file before FreeConsole()
    is called. Procmon shows FreeConsole closing file handle
    subsequent writes to stderr fail with ERROR_INVALID_HANDLE because
    WriteFile() cannot operate on the closed handle. This results in losing
    all messages after startup, including warnings, errors, notes, and
    crash reports.
    
    Additionally, some users reported stderr being redirected to
    multi-master.info and failing at startup, but this could not be reproduced
    here.
    
    The workaround involves calling FreeConsole() right before the redirection of
    stdout/stderr. This fix has been tested with XAMPP and via cmd.exe using
    "start mysqld". Automated testing using MTR is challenging for this case.
    
    The fix is only applicable to version 10.5. In later versions, the
    FreeConsole() call has been removed.
    9fdc0e54
mysqld.cc 341 KB