server icon indicating copy to clipboard operation
server copied to clipboard

MSSQL not reachable after upgrade to debian buster (and docker)

Open faulix opened this issue 7 years ago • 6 comments

Hello,

I updated my system to debian buster and in the course of this update docker got updated. Since that time I can't start bitwarden anymore.

First some system information:

root@stefankuhn:/var/docker# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 10 (buster)
Release:	10
Codename:	buster
root@stefankuhn:/var/docker# docker-compose version
docker-compose version 1.22.0, build f46880fe
docker-py version: 3.4.1
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.1.0f  25 May 2017
root@stefankuhn:/var/docker# docker version
Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:29:29 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:28:05 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

I run updateself and update and reach the follwoing point:

Bitwarden is up and running!
===================================================

visit https://mydomain.la
to update, run `./bitwarden.sh updateself` and then `./bitwarden.sh update`

Pausing 60 seconds for database to come online. Please wait...
1.32.0: Pulling from bitwarden/setup
Digest: sha256:e88f1611ff88c77a6255c49189ac3c965aaa3576fa6980ba54f2be10a96907b5
Status: Image is up to date for bitwarden/setup:1.32.0
docker.io/bitwarden/setup:1.32.0

Migrating database.

Unhandled Exception: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Resource temporarily unavailable
   at System.Net.Dns.InternalGetHostByName(String hostName)
   at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
   at System.Data.SqlClient.SNI.SNITCPHandle.Connect(String serverName, Int32 port, TimeSpan timeout)
   at System.Data.SqlClient.SNI.SNITCPHandle..ctor(String serverName, Int32 port, Int64 timerExpire, Object callbackObject, Boolean parallel)
   --- End of inner exception stack trace ---
   at Bit.Setup.Program.MigrateDatabase(Int32 attempt) in /home/appveyor/projects/server/util/Setup/Program.cs:line 193
   at Bit.Setup.Program.Main(String[] args) in /home/appveyor/projects/server/util/Setup/Program.cs:line 65

As next step I checked the MSSQL logs (errorlog), but couldn't find anything:

2019-09-13 06:37:32.95 Server      Microsoft SQL Server 2017 (RTM-CU14) (KB4484710) - 14.0.3076.1 (X64)
        Mar 12 2019 19:29:19
        Copyright (C) 2017 Microsoft Corporation
        Express Edition (64-bit) on Linux (Ubuntu 16.04.6 LTS)
2019-09-13 06:37:32.96 Server      UTC adjustment: 0:00
2019-09-13 06:37:32.96 Server      (c) Microsoft Corporation.
2019-09-13 06:37:32.96 Server      All rights reserved.
2019-09-13 06:37:32.97 Server      Server process ID is 28.
2019-09-13 06:37:32.97 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2019-09-13 06:37:32.97 Server      Registry startup parameters:
         -d /var/opt/mssql/data/master.mdf
         -l /var/opt/mssql/data/mastlog.ldf
         -e /var/opt/mssql/log/errorlog
2019-09-13 06:37:32.98 Server      SQL Server detected 2 sockets with 1 cores per socket and 1 logical processors per socket, 2 total logical processors; using 1 logical processors based on SQL Server licensing. This is an informational message; no user action is requi$
2019-09-13 06:37:32.99 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2019-09-13 06:37:32.99 Server      Detected 3096 MB of RAM. This is an informational message; no user action is required.
2019-09-13 06:37:32.99 Server      Using conventional memory in the memory manager.
2019-09-13 06:37:34.58 Server      Buffer pool extension is already disabled. No action is necessary.
2019-09-13 06:37:35.27 Server      InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
2019-09-13 06:37:35.27 Server      Implied authentication manager initialization failed. Implied authentication will be disabled.
2019-09-13 06:37:35.29 Server      Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2']. Allowed TLS ciphers are ['ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-$
2019-09-13 06:37:35.43 Server      Node configuration: node 0: CPU mask: 0x0000000000000001:0 Active CPU mask: 0x0000000000000001:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action i$
2019-09-13 06:37:35.43 Server      The maximum number of dedicated administrator connections for this instance is '1'
2019-09-13 06:37:35.45 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2019-09-13 06:37:35.46 Server      In-Memory OLTP initialized on lowend machine.
2019-09-13 06:37:35.59 Server      Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is requi$
2019-09-13 06:37:35.60 Server      Query Store settings initialized with enabled = 1,
2019-09-13 06:37:35.69 Server      Software Usage Metrics is disabled.
2019-09-13 06:37:35.74 spid6s      Starting up database 'master'.
2019-09-13 06:37:36.88 spid6s      Service Master Key could not be decrypted using one of its encryptions. See sys.key_encryptions for details.
2019-09-13 06:37:36.89 spid6s      An error occurred during Service Master Key initialization. SQLErrorCode=33095, State=8, LastOsError=0.
2019-09-13 06:37:37.04 spid6s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2019-09-13 06:37:37.04 spid6s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2019-09-13 06:37:37.23 spid6s      SQL Trace ID 1 was started by login "sa".
2019-09-13 06:37:37.25 spid6s      Server name is '417bccd64d81'. This is an informational message only. No user action is required.
2019-09-13 06:37:37.29 spid21s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2019-09-13 06:37:37.30 spid6s      Starting up database 'msdb'.
2019-09-13 06:37:37.31 spid21s     Always On: The availability replica manager is waiting for the instance of SQL Server to allow client connections. This is an informational message only. No user action is required.
2019-09-13 06:37:37.32 spid11s     Starting up database 'mssqlsystemresource'.
2019-09-13 06:37:37.33 spid11s     The resource database build version is 14.00.3076. This is an informational message only. No user action is required.
2019-09-13 06:37:37.41 spid11s     Starting up database 'model'.
2019-09-13 06:37:38.22 spid11s     Polybase feature disabled.
2019-09-13 06:37:38.22 spid11s     Clearing tempdb database.
2019-09-13 06:37:38.59 spid18s     A self-generated certificate was successfully loaded for encryption.
2019-09-13 06:37:38.63 spid18s     Server is listening on [ 'any' <ipv6> 1433].
2019-09-13 06:37:38.64 spid18s     Server is listening on [ 'any' <ipv4> 1433].
2019-09-13 06:37:38.67 spid18s     Dedicated administrator connection support was not started because it is disabled on this edition of SQL Server. If you want to use a dedicated administrator connection, restart SQL Server using the trace flag 7806. This is an informa$
2019-09-13 06:37:38.70 spid18s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
2019-09-13 06:37:39.13 Server      Failed to verify the Authenticode signature of 'C:\binn\secforwarder.dll'. Signature verification of SQL Server DLLs will be skipped. Genuine copies of SQL Server are signed. Failure to verify the Authenticode signature might indicate$
2019-09-13 06:37:39.37 spid11s     Starting up database 'tempdb'.
2019-09-13 06:37:40.23 spid21s     The Service Broker endpoint is in disabled or stopped state.
2019-09-13 06:37:40.24 spid21s     The Database Mirroring endpoint is in disabled or stopped state.
2019-09-13 06:37:40.31 spid21s     Service Broker manager has started.
2019-09-13 06:37:40.35 spid6s      Recovery is complete. This is an informational message only. No user action is required.
2019-09-13 06:42:37.29 spid51      Using 'dbghelp.dll' version '4.0.5'
2019-09-13 06:44:19.57 spid51      Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required.
2019-09-13 06:44:19.67 spid51      Using 'xplog70.dll' version '2017.140.3076' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.
2019-09-13 06:44:19.94 spid51      Starting up database 'vault'.
2019-09-13 06:44:20.19 spid51      Parallel redo is started for database 'vault' with worker pool size [1].
2019-09-13 06:44:20.28 spid51      Parallel redo is shutdown for database 'vault' with worker pool size [1].
2019-09-13 06:53:31.31 spid6s      Always On: The availability replica manager is going offline because SQL Server is shutting down. This is an informational message only. No user action is required.
2019-09-13 06:53:31.32 spid6s      SQL Server is terminating in response to a 'stop' request from Service Control Manager. This is an informational message only. No user action is required.
2019-09-13 06:53:32.15 spid21s     Service Broker manager has shut down.
2019-09-13 06:53:32.28 spid6s      SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.

As MSSQL seems to be fine, I proceeded to the web server (nginx), where I found the following message in the the error log: 2019/09/13 06:53:03 [emerg] 1#1: host not found in upstream "web" in /etc/nginx/conf.d/default.conf:45 Following up this I went to the default.conf, where I found the following directives from line 44-51:

  location / {
    proxy_pass http://web:5000/;
    include /etc/nginx/security-headers-ssl.conf;
    include /etc/nginx/security-headers.conf;
    add_header Content-Security-Policy "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://haveibeenpwned.com https://www.gravatar.com; child-src 'self' https://*.duosecurity.com; frame-src 'self' https://*.duosecurity.com; connect-src '$
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Robots-Tag "noindex, nofollow";
  }

To be honest, now I have no idea how to proceed, has anyone an idea?

Thanks for your support.

faulix avatar Sep 13 '19 07:09 faulix

Was curious, so as a test, I quickly went with a fresh Debian 10 install (https://www.debian.org/distrib/netinst).

Updated the system / installed docker :

root@ubuntu:~# id
uid=0(root) gid=0(root) groups=0(root)
root@ubuntu:~# apt-get update
(...)
root@ubuntu:~# apt-get -y dist-upgrade
(...)
#https://docs.docker.com/install/linux/docker-ce/debian/
root@ubuntu:~# apt-get install docker-ce docker-ce-cli containerd.io
(...)
root@ubuntu:~# curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
root@ubuntu:~# chmod 755 /usr/local/bin/docker-compose
root@ubuntu:~# reboot

And installed Bitwarden :

root@ubuntu:/bw# id
uid=0(root) gid=0(root) groups=0(root)
root@ubuntu:/bw# curl -Lso bitwarden.sh https://go.btwrdn.co/bw-sh && chmod +x bitwarden.sh
root@ubuntu:/bw# ./bitwarden.sh install
(...)
(!) Enter your installation id (get at https://bitwarden.com/host): //hidden
(!) Enter your installation key: //hidden
(!) Do you have a SSL certificate to use? (y/n): n
(!) Do you want to generate a self-signed SSL certificate? (y/n): y
(...)
Next steps, run:
`./bitwarden.sh start`
root@ubuntu:/bw# ./bitwarden.sh start
(...)
Bitwarden is up and running!
to update, run `./bitwarden.sh updateself` and then `./bitwarden.sh update`
root@ubuntu:/bw# docker ps -a
CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS                   PORTS                                                 NAMES
81c5e4bddf84        bitwarden/nginx:1.32.0           "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   80/tcp, 0.0.0.0:80->8080/tcp, 0.0.0.0:443->8443/tcp   bitwarden-nginx
95cd5b27c5f9        bitwarden/admin:1.32.0           "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   5000/tcp                                              bitwarden-admin
dedc4dc59ef2        bitwarden/icons:1.32.0           "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   5000/tcp                                              bitwarden-icons
0e4be01655e4        bitwarden/attachments:1.32.0     "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   5000/tcp                                              bitwarden-attachments
997fae5864ac        bitwarden/identity:1.32.0        "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   5000/tcp                                              bitwarden-identity
e4d2c090c15e        bitwarden/api:1.32.0             "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   5000/tcp                                              bitwarden-api
69ef28f3e095        bitwarden/web:2.12.0             "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   5000/tcp                                              bitwarden-web
96abee0ab8a3        bitwarden/events:1.32.0          "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   5000/tcp                                              bitwarden-events
287f1b394a9e        bitwarden/notifications:1.32.0   "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   5000/tcp                                              bitwarden-notifications
76308154784f        bitwarden/mssql:1.32.0           "/entrypoint.sh"    7 minutes ago       Up 7 minutes (healthy)   1433/tcp                                              bitwarden-mssql

As you see, everything went fine, and Bitwarden is properly reachable / usable. Try to go first with a fresh Bitwarden installation to see if it goes flawlessly ?

Mart124 avatar Nov 21 '19 08:11 Mart124

@Mart124 Thank you for your effort and test.

Actually I tested it with a fresh install of Bitwarden, but I get the same error.

Unfortunately it's a productive system, therefore I don't have the possibility to take a fresh Debian installation and the system went already through couple of upgrades, therefore it might be a problem with a "grown" system.

faulix avatar Nov 21 '19 09:11 faulix

Did you install docker as shown above, using last version of docker-ce ?

Mart124 avatar Nov 23 '19 10:11 Mart124

@Mart124 Yes, I did. However, the new version doesn't require root, therefore I set it up with regular user permissions.

The installed versions are:

containerd.io 1.2.10-3
docker-ce-cli 5:19.03.5~3-0~debian-buster
docker-ce 5:19.03.5~3-0~debian-buster

Further tests show, that the issue seems to be, that the hostnames can't get resolved. If I assign static IPs and replace the hostnames with the IPs, then it seems to work (partially). For some services I can't access the configuration/code, therefore overall it still doesn't work as I can't replace everywhere the hostnames.

faulix avatar Nov 25 '19 14:11 faulix

Note that on Debian 10, to install Docker, you can also simply do :

apt-get install docker.io
apt-get install docker-compose

Bitwarden tested with this, and it works perfectly 👍

Mart124 avatar Jan 09 '20 22:01 Mart124

Closing this issue as it appears the originally posted problem has been resolved. If this happens again or continues to be an issue please feel free to re-open this issue and let us know, along with any additional detail to assist with reproduction and root cause analysis.

djsmith85 avatar Dec 12 '21 13:12 djsmith85