Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSSQL Container crashed on Colima / Mac #83

Closed
jwedel opened this issue Aug 30, 2024 · 2 comments
Closed

MSSQL Container crashed on Colima / Mac #83

jwedel opened this issue Aug 30, 2024 · 2 comments

Comments

@jwedel
Copy link

jwedel commented Aug 30, 2024

Due to the fact that the Oracle XE test container is only available for x64 architectures ATM, we needed to use Colima. The oracle container works fine but the MSSQL does not start, when I just run the used image, I can see the following errors:

➜  colima docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong\!Password" -e "MSSQL_PID=Evaluation" -p 1433:1433  --name sqlpreview --hostname sqlpreview mcr.microsoft.com/mssql/server:2019-CU18-ubuntu-20.04
SQL Server 2019 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
This program has encountered a fatal error and cannot continue running at Fri Aug 30 12:20:26 2024
The following diagnostic information is available:

         Reason: 0x00000001
         Signal: SIGABRT - Aborted (6)
          Stack:
                 IP               Function
                 ---------------- --------------------------------------
                 00005657df105bec <unknown>
                 00005657df105632 <unknown>
                 00005657df104c41 <unknown>
                 00007c52aa724090 killpg+0x40
                 00007c52aa72400b gsignal+0xcb
                 00007c52aa703859 abort+0x12b
                 00005657df08e2a2 <unknown>
                 00005657df11a154 <unknown>
                 00005657df14f248 <unknown>
                 00005657df14f02a <unknown>
                 00005657df09a11a <unknown>
                 00005657df099d6f <unknown>
        Process: 9 - sqlservr
         Thread: 84 (application thread 0x140)
    Instance Id: 5ac0f825-a6d2-4c1a-a411-7c98228dcb7d
       Crash Id: 05a4bb87-7b7f-4f24-be19-0b4a95194baf
    Build stamp: f708684a2cfcb51177273c54f975ed8c62029cbc89aa962bf7d6b956f01a0c27
   Distribution: Ubuntu 20.04.5 LTS
     Processors: 6
   Total Memory: 4100014080 bytes
      Timestamp: Fri Aug 30 12:20:26 2024
     Last errno: 2
Last errno text: No such file or directory
Capturing a dump of 9
Successfully captured dump: /var/opt/mssql/log/core.sqlservr.8_30_2024_12_20_27.9
Executing: /opt/mssql/bin/handle-crash.sh with parameters
     handle-crash.sh
     /opt/mssql/bin/sqlservr
     9
     /opt/mssql/bin
     /var/opt/mssql/log/

     5ac0f825-a6d2-4c1a-a411-7c98228dcb7d
     05a4bb87-7b7f-4f24-be19-0b4a95194baf

     /var/opt/mssql/log/core.sqlservr.8_30_2024_12_20_27.9

Ubuntu 20.04.5 LTS
Capturing core dump and information to /var/opt/mssql/log...

Now, when I use mcr.microsoft.com/mssql/server:latest, it works (starting the container). I don't know which version "latest" actually is as the most recent version 2019-CU27-ubuntu-20.04 does NOT work some reason.,

However, this version is not compatible with the test container code.

To eventually get it running, I needed to change the wait strategy (notice the "-C" and the "mssql-tools18"):

  private sealed class WaitUntilMssql18Available : IWaitUntil
  {
    // command has moved from "mssql-tools" to "mssql-tools18" in more recent versions of the image 
    // -C accepts self signed cert
    private readonly string[] _command = { "/opt/mssql-tools18/bin/sqlcmd", "-C", "-Q", "SELECT 1;" }; 

    /// <inheritdoc />
    public async Task<bool> UntilAsync(IContainer container)
    {
      var execResult = await container.ExecAsync(_command)
        .ConfigureAwait(false);

      return 0L.Equals(execResult.ExitCode);
    }
  }
}

Same when executing commands:

public static class ContainerExtension {
  public static async Task<ExecResult> ExecScriptAsyncPatched(this DockerContainer container, string scriptContent, CancellationToken ct = default)
  {
    var scriptFilePath = string.Join("/", string.Empty, "tmp", Guid.NewGuid().ToString("D"), Path.GetRandomFileName());

    await container.CopyAsync(Encoding.Default.GetBytes(scriptContent), scriptFilePath, Unix.FileMode644, ct)
      .ConfigureAwait(false);

    return await container.ExecAsync(new[] { "/opt/mssql-tools18/bin/sqlcmd", "-C", "-b", "-r", "1", "-U", "sa", "-P", "yourStrong(!)Password", "-i", scriptFilePath }, ct)
      .ConfigureAwait(false);
  }
}

So, with this rather ugly hack and hardcoding the credentials, the test container starts and my tests work.

So, would it be possible to update to the latest mssql container version and adjust the exec commands? I could provide a PR for the changes, if it helps.

@jwedel
Copy link
Author

jwedel commented Aug 30, 2024

I think it's actually related to

microsoft/mssql-docker#881

So this seems to be a problem when MSSQL is running on Ubuntu 24.04 which colima apparently is:

wej2be@colima:/Users/wej2be/.config/colima$ cat /etc/*-release
...
PRETTY_NAME="Ubuntu 24.04 LTS"
...

@jwedel
Copy link
Author

jwedel commented Aug 30, 2024

Wrong repo, sorry

@jwedel jwedel closed this as completed Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant