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 Backup Issues #856

Closed
evakq8r opened this issue Aug 10, 2020 · 23 comments
Closed

MSSQL Backup Issues #856

evakq8r opened this issue Aug 10, 2020 · 23 comments

Comments

@evakq8r
Copy link

evakq8r commented Aug 10, 2020

Hi,

I'm having issues with MSSQL backups of my database no longer automatically backing up. Most recent error:

2020-08-10 00:00:00.62 Backup      BackupIoRequest::ReportIoError: write failure on backup device '/etc/bitwarden/mssql/backups/vault_FULL_20200810_000000.BAK'. Operating system error Insufficient bytes transferred. Common causes are backup configuration, insufficient disk space, or other problems with the storage subsystem such as corruption or hardware failure. Check errorlogs/application-logs for detailed messages and correct error conditions..
Internal I/O request 0x000000139EA72600: Op: Write, pBuffer: 0x0000000982900000, Size: 4096, Position: 0, SOS: Internal: 0xE, InternalHigh: 0x0, Offset: 0x0, OffsetHigh: 0x0, m_buf: 0x0000000982900000, m_len: 4096, m_actualBytes: 0, m_errcode: 4294967294, BackupFile: /etc/bitwarden/mssql/backups/vault_FULL_20200810_000000.BAK
2020-08-10 00:00:00.63 Backup      Error: 3041, Severity: 16, State: 1.
2020-08-10 00:00:00.63 Backup      BACKUP failed to complete the command BACKUP DATABASE vault. Check the backup application log for detailed messages.

The last successful backup was last Friday (07/08), but wasn't aware of this until yesterday. Prior to this issue, my bitwarden-mssql container was constantly restarting due to this error:

Operating system error 317(The system cannot find message text for message number 0x%1 in the message file for %2.) encountered.

After a few hours of troubleshooting, it was only fixed by setting the database_docker_volume parameter to true (was false) in the config.yml file. Changing that flag however made me lose access to the existing databases, so I ended up restoring the most recent backup following this guide: #651 and that allowed access to my password database again.

Come today and the backup error log above is now my new problem, which I am having issues fixing as I don't really know where to start or which logs to look into.

The bitwarden install sits on an Unraid environment (which as best as I can tell is probably not fully supported for how I've implemented it). I wasn't able to use bitwarden_rs from the CA App store as the installation kept throwing C# errors, which the dev wasn't sure why. I managed to get the official self-hosted instance of bitwarden working by making a few changes to the docker-compose and docker-compose-override yamls and this has been working perfectly fine for over 3 months.

TL;DR: Any idea why MSSQL is no longer backing up my database based on the error(s) above?

@Greenderella
Copy link
Member

I suggest that you write a support ticket here: https://bitwarden.com/contact/ so you can share with us your logs and all the modifications that you have done to the docker-compose and docker-compose-override yaml.

@evakq8r
Copy link
Author

evakq8r commented Aug 10, 2020

The only logs that I can see regarding the error are pasted above, but I have emailed what you've requested through and explained why those settings have been set.

@kspearrin
Copy link
Member

This likely has something to do with the filesystem environment. Mysql on docker is a bit flakey with filesystems and only works well under ext4 as far as I know. Otherwise, you need to use a docker volume as you have discovered.

@evakq8r
Copy link
Author

evakq8r commented Aug 10, 2020

Seems strange for it to have failed all of a sudden after 3 months of zero changes. In addition, while the docker volume works for gaining access to my database, the auto backups are failing... which leaves me somewhat uneasy in the event I lose my databases again for corruption or some such.

I'm hoping that's also not filesystem related?

@kspearrin
Copy link
Member

I don't think the backup volume is mapped to the docker volume, so you would likely need to change that also using a docker-compose modification or override.

    volumes:
      - ../mssql/data:/var/opt/mssql/data
      - ../logs/mssql:/var/opt/mssql/log
      - ../mssql/backups:/etc/bitwarden/mssql/backups

@evakq8r
Copy link
Author

evakq8r commented Aug 10, 2020

When I swapped the docker database volume from false to true, the yaml changed to include volumes and added this to the bottom of the docker-compose yaml:

volumes:
  mssql_data:

I didn't fill in anything after mssql_data: at the bottom, because the same parameter seems to be prefilled already under bitwarden/mssql:

volumes:
  - mssql_data:/var/opt/mssql/data
  - ../logs/mssql:/var/opt/mssql/log
  - ../mssql/backups:/etc/bitwarden/mssql/backups

To me, that suggests it should be mapped? Or are you saying the second field needs to be manually specified?

@kspearrin
Copy link
Member

kspearrin commented Aug 10, 2020

You also need to pay the backups to a docker volume:

This:

- ../mssql/backups:/etc/bitwarden/mssql/backups

And probably logs too.

@evakq8r
Copy link
Author

evakq8r commented Aug 10, 2020

So, you're saying replacing the existing volumes of:

volumes:
  - mssql_data:/var/opt/mssql/data
  - ../logs/mssql:/var/opt/mssql/log
  - ../mssql/backups:/etc/bitwarden/mssql/backups

To something like:

volumes:
  - mssql_data:/var/opt/mssql/data
  - ../logs/mssql:/mnt/user/appdata/bitwarden/bwdata/logs
  - ../mssql/backups:/mnt/user/appdata/bitwarden/bwdata/mssql/backups

Or am I interpreting that incorrectly?

@kspearrin
Copy link
Member

Change it to something like this:

volumes:
  - mssql_data:/var/opt/mssql/data
  - mssql_data:/var/opt/mssql/log
  - mssql_data:/etc/bitwarden/mssql/backups

@evakq8r
Copy link
Author

evakq8r commented Aug 10, 2020

Ok, I can give that a go. Can you elaborate why mssql_data needs to be defined three times though? I thought the existing logs/mssql and mssql/backups were the only things changing? Am curious is all.

EDIT: I've made the suggested changes to the bitwarden-mssql section of the docker-compose.yaml file, like so:

services:
  mssql:
    image: bitwarden/mssql:1.36.1
    container_name: bitwarden-mssql
    restart: always
    stop_grace_period: 60s
    volumes:
      - mssql_data:/var/opt/mssql/data
      - mssql_data:/var/opt/mssql/log
      - mssql_data:/etc/bitwarden/mssql/backups
    env_file:
      - mssql.env
      - ../env/uid.env
      - ../env/mssql.override.env

If that is how you're asking to set it (sorry for the thousand questions), auto backup is due to trigger in ~40 minutes so we should know by then if it has worked or not.

@evakq8r
Copy link
Author

evakq8r commented Aug 10, 2020

Hmm, it seems the changes made have caused the backup to not run at all.

2020-08-10 13:44:09.95 Server      The licensing PID was successfully processed. The new edition is [Express Edition].
2020-08-10 13:44:10.43 Server      Microsoft SQL Server 2017 (RTM-CU18) (KB4527377) - 14.0.3257.3 (X64) 
        Nov 16 2019 01:14:50 
        Copyright (C) 2017 Microsoft Corporation
        Express Edition (64-bit) on Linux (Ubuntu 16.04.6 LTS)
2020-08-10 13:44:10.43 Server      UTC adjustment: 0:00
2020-08-10 13:44:10.43 Server      (c) Microsoft Corporation.
2020-08-10 13:44:10.43 Server      All rights reserved.
2020-08-10 13:44:10.43 Server      Server process ID is 32.
2020-08-10 13:44:10.43 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2020-08-10 13:44:10.43 Server      Registry startup parameters: 
         -d /var/opt/mssql/data/master.mdf
         -l /var/opt/mssql/data/mastlog.ldf
         -e /var/opt/mssql/log/errorlog
2020-08-10 13:44:10.44 Server      SQL Server detected 1 sockets with 6 cores per socket and 12 logical processors per socket, 12 total logical processors; using 8 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2020-08-10 13:44:10.44 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2020-08-10 13:44:10.44 Server      Detected 25716 MB of RAM. This is an informational message; no user action is required.
2020-08-10 13:44:10.44 Server      Using conventional memory in the memory manager.
2020-08-10 13:44:10.79 Server      Buffer pool extension is already disabled. No action is necessary. 
2020-08-10 13:44:10.99 Server      InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
2020-08-10 13:44:10.99 Server      Implied authentication manager initialization failed. Implied authentication will be disabled.
2020-08-10 13:44:10.99 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-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:!DHE-RSA-AES256-GCM-SHA384:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES256-SHA:!DHE-RSA-AES128-SHA'].
2020-08-10 13:44:11.04 Server      The maximum number of dedicated administrator connections for this instance is '1'
2020-08-10 13:44:11.04 Server      Node configuration: node 0: CPU mask: 0x00000000000000ff:0 Active CPU mask: 0x00000000000000ff:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2020-08-10 13:44:11.06 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.
2020-08-10 13:44:11.07 Server      In-Memory OLTP initialized on standard machine.
2020-08-10 13:44:11.10 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 required.
ForceFlush is enabled for this instance. 
2020-08-10 13:44:11.10 Server      Query Store settings initialized with enabled = 1, 
2020-08-10 13:44:11.11 Server      Software Usage Metrics is disabled.
2020-08-10 13:44:11.11 spid6s      Starting up database '<database>'.
ForceFlush feature is enabled for log durability.
2020-08-10 13:44:11.43 spid6s      Service Master Key could not be decrypted using one of its encryptions. See sys.key_encryptions for details.
2020-08-10 13:44:11.43 spid6s      An error occurred during Service Master Key initialization. SQLErrorCode=33095, State=8, LastOsError=0.
2020-08-10 13:44:11.48 spid6s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2020-08-10 13:44:11.49 spid6s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2020-08-10 13:44:11.59 spid6s      SQL Trace ID 1 was started by login "<username>".
2020-08-10 13:44:11.72 spid6s      Server name is '<hostname>'. This is an informational message only. No user action is required.
2020-08-10 13:44:11.72 spid21s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2020-08-10 13:44:11.73 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.
2020-08-10 13:44:11.74 spid6s      Starting up database 'msdb'.
2020-08-10 13:44:11.74 spid11s     Starting up database 'mssqlsystemresource'.
2020-08-10 13:44:11.74 spid11s     The resource database build version is 14.00.3257. This is an informational message only. No user action is required.
2020-08-10 13:44:11.75 spid11s     Starting up database 'model'.
2020-08-10 13:44:11.96 spid18s     A self-generated certificate was successfully loaded for encryption.
2020-08-10 13:44:11.96 spid18s     Server is listening on [ 'any' <ipv6> 1433].
2020-08-10 13:44:11.96 spid18s     Server is listening on [ 'any' <ipv4> 1433].
2020-08-10 13:44:11.97 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 informational message only. No user action is required.
2020-08-10 13:44:11.97 spid18s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
2020-08-10 13:44:12.09 spid11s     Polybase feature disabled.
2020-08-10 13:44:12.09 spid11s     Clearing tempdb database.
2020-08-10 13:44:12.39 spid11s     Starting up database 'tempdb'.
2020-08-10 13:44:12.55 spid21s     The Service Broker endpoint is in disabled or stopped state.
2020-08-10 13:44:12.55 spid21s     The Database Mirroring endpoint is in disabled or stopped state.
2020-08-10 13:44:12.61 spid21s     Service Broker manager has started.
2020-08-10 13:44:12.68 spid6s      Recovery is complete. This is an informational message only. No user action is required.
2020-08-10 13:44:26.84 spid52      Starting up database 'vault'.
2020-08-10 13:44:26.91 spid52      Parallel redo is started for database 'vault' with worker pool size [4].
2020-08-10 13:44:27.01 spid52      Parallel redo is shutdown for database 'vault' with worker pool size [4].

This is all that is available in the bitwarden-mssql log files (the backup folder is also no different).

@evakq8r
Copy link
Author

evakq8r commented Aug 11, 2020

Ok, update to this... turns out the container was in UTC this whole time :\ which is why nothing happened when I said it would have.

The logs suggest the backup WAS successful, but the file has not appeared in the backups folder on the host, only within the container.

2020-08-11 00:00:00.57 Backup      Database backed up. Database: vault, creation date(time): 2020/08/09(15:20:31), pages dumped: 988, first LSN: 50:29448:92, last LSN: 50:29504:1, number of dump devices: 1, device information: (FILE=1, TYPE=DISK: {'/etc/bitwarden/mssql/backups/vault_FULL_20200811_000000.BAK'}). This is an informational message only. No user action is required.
2020-08-11 00:00:00.69 Backup      BACKUP DATABASE successfully processed 980 pages in 0.080 seconds (95.654 MB/sec).

From Unraid host:

root@<hostname>:/mnt/user/docker/bitwarden/bwdata/mssql/backups# ls -la
total 85480
drwxrwxrwx 1 65534 65534     660 Aug 10 09:30 ./
drwxrwxrwx 1 65534 65534      22 Jul 26 00:14 ../
-rw-r----- 1 65534 65534 7856128 Jul 27 09:30 vault_FULL_20200727_000000.BAK
-rw-r----- 1 65534 65534 7921664 Jul 28 09:30 vault_FULL_20200728_000000.BAK
-rw-r----- 1 65534 65534 7987200 Jul 29 09:30 vault_FULL_20200729_000000.BAK
-rw-r----- 1 65534 65534 7987200 Jul 30 09:30 vault_FULL_20200730_000000.BAK
-rw-r----- 1 65534 65534 7987200 Jul 31 09:30 vault_FULL_20200731_000000.BAK
-rw-r----- 1 65534 65534 8052736 Aug  1 09:30 vault_FULL_20200801_000000.BAK
-rw-r----- 1 65534 65534 8052736 Aug  2 09:30 vault_FULL_20200802_000000.BAK
-rw-r----- 1 65534 65534 7921664 Aug  3 09:30 vault_FULL_20200803_000000.BAK
-rw-r----- 1 65534 65534 7921664 Aug  4 09:30 vault_FULL_20200804_000000.BAK
-rw-r----- 1 65534 65534 7921664 Aug  5 09:30 vault_FULL_20200805_000000.BAK
-rw-r----- 1 65534 65534 7921664 Aug  6 09:30 vault_FULL_20200806_000000.BAK

From within the bitwarden-mssql container:

root@<container id>:/etc/bitwarden/mssql/backups# ls -la     
total 278848
drwxr-xr-x 1 nobody nogroup       542 Aug 11 00:00 .
drwxr-xr-x 1 nobody nogroup        14 Aug 10 13:44 ..
-rw-r----- 1 nobody nogroup     77824 Aug 10 13:44 HkEngineEventFile_0_132415406510880000.xel
-rw-r----- 1 nobody nogroup      7119 Aug 11 00:00 errorlog
-rw-r----- 1 nobody nogroup         0 Aug 10 13:44 errorlog.1
-rw-r----- 1 nobody nogroup   1048576 Aug 11 00:00 log.trc
-rw-r----- 1 nobody nogroup         0 Aug 11 00:00 log_1.trc
-rw-r----- 1 nobody nogroup   4194304 Aug 10 13:44 master.mdf
-rw-r----- 1 nobody nogroup   2097152 Aug 11 00:00 mastlog.ldf
-rw-r----- 1 nobody nogroup   8388608 Aug 10 13:44 model.mdf
-rw-r----- 1 nobody nogroup   8388608 Aug 10 13:44 modellog.ldf
-rw-r----- 1 nobody nogroup  15466496 Aug 10 13:44 msdbdata.mdf
-rw-r----- 1 nobody nogroup    786432 Aug 11 00:00 msdblog.ldf
-rw-r----- 1 nobody nogroup       156 Aug 10 13:44 sqlagentstartup.log
-rw-r----- 1 nobody nogroup   2080768 Aug 11 05:52 system_health_0_132415406515270000.xel
-rw-r----- 1 nobody nogroup   8388608 Aug 10 13:44 tempdb.mdf
-rw-r----- 1 nobody nogroup   8388608 Aug 10 13:44 templog.ldf
-rw-r----- 1 nobody nogroup  75497472 Aug 11 00:00 vault.mdf
-rw-r----- 1 nobody nogroup   8118272 Aug 11 00:00 vault_FULL_20200811_000000.BAK <<<<<<<<<<<<
-rw-r----- 1 nobody nogroup 142606336 Aug 11 05:45 vault_log.ldf

@kspearrin would this be because the backups (and probably logs) folder is now mapped within the container only? Not pointing towards the host/docker volume?

@kspearrin
Copy link
Member

If you are using a docker volume, mssql_data, then the backup file is in there, not mapped back to your host.

@evakq8r
Copy link
Author

evakq8r commented Aug 12, 2020

Well, as far as I can tell the mssql_data docker volume doesn't exist anywhere (not within the Bitwarden host folder, and not within the mssql container).

I had a thought of working around it with an Unraid user script to copy the new files nightly, but docker doesn't support wildcard docker cp (been an outstanding request for 6 years +) as the name of the file changes per day.

While the backups are now working, I can no longer access them without doing a docker cp from container to host, which isn't ideal.

@kspearrin
Copy link
Member

You may want to read more about how to interact with docker volumes on their website:
https://docs.docker.com/storage/volumes/

@evakq8r
Copy link
Author

evakq8r commented Aug 14, 2020

Seems like I'm getting nowhere with this :(

From what I've tried interpreting with that link, I have modified the docker-compose.yaml with the following:

services:
  mssql:
    image: bitwarden/mssql:1.36.1
    container_name: bitwarden-mssql
    restart: always
    stop_grace_period: 60s
    volumes:
      - mssql_data:/var/opt/mssql/data
      - mssql_data:/var/opt/mssql/log
      - mssql_backup:/etc/bitwarden/mssql/backups
    env_file:
      - mssql.env
      - ../env/uid.env
      - ../env/mssql.override.env
volumes:
  mssql_data:
  mssql_backup:

docker-compose-override.yaml:

volumes:
  mssql_backup:
    driver_opts:
      type: none
      device: /mnt/user/docker/bitwarden/bwdata/mssql/backups/
      o: bind

Failed this morning:

2020-08-14 00:00:00.76 Backup      BackupIoRequest::ReportIoError: write failure on backup device '/etc/bitwarden/mssql/backups/vault_FULL_20200814_000000.BAK'. Operating system error Insufficient bytes transferred. Common causes are backup configuration, insufficient disk space, or other problems with the storage subsystem such as corruption or hardware failure. Check errorlogs/application-logs for detailed messages and correct error conditions..
Internal I/O request 0x00000012DEAFE600: Op: Write, pBuffer: 0x0000000682910000, Size: 4096, Position: 0, SOS: Internal: 0xE, InternalHigh: 0x0, Offset: 0x0, OffsetHigh: 0x0, m_buf: 0x0000000682910000, m_len: 4096, m_actualBytes: 0, m_errcode: 4294967294, BackupFile: /etc/bitwarden/mssql/backups/vault_FULL_20200814_000000.BAK
2020-08-14 00:00:00.76 Backup      Error: 3041, Severity: 16, State: 1.
2020-08-14 00:00:00.76 Backup      BACKUP failed to complete the command BACKUP DATABASE vault. Check the backup application log for detailed messages.

The error sounds like write permission issues to the host, so I checked the backup folder and it has 777 permissions, but the owner is 65534:65534 - not exactly sure who or what that is, but it's a recurring theme across the bitwarden folders.

root@<hostname>~# ls -la /mnt/user/docker/bitwarden/bwdata/mssql/
total 0
drwxrwxrwx 1 65534 65534  22 Jul 26 00:14 ./
drwxrwxrwx 1 65534 65534 168 Jul 26 12:12 ../
drwxrwxrwx 1 65534 65534 840 Aug 14 09:30 backups/
drwxrwxrwx 1 65534 65534 282 Jul 26 00:15 data/

From what I've read, Unraid dockers usually have issues if the owner is not set to nobody:users, so I've changed just the backup folder to that:

root@<hostname>:~# chown nobody:users /mnt/user/docker/bitwarden/bwdata/mssql/backups

root@<hostname>:~# ls -la /mnt/user/docker/bitwarden/bwdata/mssql/
total 0
drwxrwxrwx 1  65534 65534  22 Jul 26 00:14 ./
drwxrwxrwx 1  65534 65534 168 Jul 26 12:12 ../
drwxrwxrwx 1 nobody users 840 Aug 14 09:30 backups/
drwxrwxrwx 1  65534 65534 282 Jul 26 00:15 data/

If it doesn't work, I'll change it back to the previous owner.

Will have to wait for the nightly backup now, but if that doesn't work I guess I'll stick to mapping everything to mssql_data and docker cp from container to host every day, for lack of other ideas.

@evakq8r
Copy link
Author

evakq8r commented Aug 15, 2020

Nope, still failed.

2020-08-15 00:00:00.87 Backup      Error: 18210, Severity: 16, State: 1.
2020-08-15 00:00:00.87 Backup      BackupIoRequest::ReportIoError: write failure on backup device '/etc/bitwarden/mssql/backups/vault_FULL_20200815_000000.BAK'. Operating system error Insufficient bytes transferred. Common causes are backup configuration, insufficient disk space, or other problems with the storage subsystem such as corruption or hardware failure. Check errorlogs/application-logs for detailed messages and correct error conditions..
Internal I/O request 0x00000012DF6A8600: Op: Write, pBuffer: 0x00000006D1450000, Size: 4096, Position: 0, SOS: Internal: 0xE, InternalHigh: 0x0, Offset: 0x0, OffsetHigh: 0x0, m_buf: 0x00000006D1450000, m_len: 4096, m_actualBytes: 0, m_errcode: 4294967294, BackupFile: /etc/bitwarden/mssql/backups/vault_FULL_20200815_000000.BAK
2020-08-15 00:00:00.88 Backup      Error: 3041, Severity: 16, State: 1.
2020-08-15 00:00:00.88 Backup      BACKUP failed to complete the command BACKUP DATABASE vault. Check the backup application log for detailed messages.

I've reverted back to using mssql_data for everything. If that works, I'll leave it as is, even though it's not working as it should be.

@evakq8r
Copy link
Author

evakq8r commented Aug 16, 2020

No longer working :(

2020-08-16 00:00:00.82 Backup      Error: 18210, Severity: 16, State: 1.
2020-08-16 00:00:00.82 Backup      BackupIoRequest::ReportIoError: write failure on backup device '/etc/bitwarden/mssql/backups/vault_FULL_20200816_000000.BAK'. Operating system error Insufficient bytes transferred. Common causes are backup configuration, insufficient disk space, or other problems with the storage subsystem such as corruption or hardware failure. Check errorlogs/application-logs for detailed messages and correct error conditions..
Internal I/O request 0x00000013AB566600: Op: Write, pBuffer: 0x0000000250940000, Size: 4096, Position: 0, SOS: Internal: 0xE, InternalHigh: 0x0, Offset: 0x0, OffsetHigh: 0x0, m_buf: 0x0000000250940000, m_len: 4096, m_actualBytes: 0, m_errcode: 4294967294, BackupFile: /etc/bitwarden/mssql/backups/vault_FULL_20200816_000000.BAK
2020-08-16 00:00:00.83 Backup      Error: 3041, Severity: 16, State: 1.
2020-08-16 00:00:00.83 Backup      BACKUP failed to complete the command BACKUP DATABASE vault. Check the backup application log for detailed messages.

docker-compose.yaml (only the mssql part as the rest of the config file has been left untouched):

version: '3'

services:
  mssql:
    image: bitwarden/mssql:1.36.1
    container_name: bitwarden-mssql
    restart: always
    stop_grace_period: 60s
    volumes:
      - mssql_data:/var/opt/mssql/data
      - mssql_data:/var/opt/mssql/log
      - mssql_data:/etc/bitwarden/mssql/backups
    env_file:
      - mssql.env
      - ../env/uid.env
      - ../env/mssql.override.env

docker-compose-override.yaml:

version: '3'

services:
  mssql:
   ulimits:
    stack:
     soft: "8192000"
     hard: "8192000"
     
networks:
  default:
    external:
      name: proxynet

This is how it was set when the backup worked once into the container (and only once).

@kspearrin, any other ideas?

@kspearrin
Copy link
Member

What are the unlimits for?

@evakq8r
Copy link
Author

evakq8r commented Aug 16, 2020

That was mentioned in the original email I sent via the Bitwarden contact form, but it's an Unraid requirement for running MSSQL on Unraid.

Without ulimits defined, the bitwarden-mssql containers throws the following errors:

Invalid mapping of address 0x14fc0f8c7000 in reserved address space below 0x400000000000. Possible causes:
1) the process (itself, or via a wrapper) starts-up its own running environment sets the stack size limit to unlimited via syscall setrlimit(2);
2) the process (itself, or via a wrapper) adjusts its own execution domain and flag the system its legacy personality via syscall personality(2);
3) sysadmin deliberately sets the system to run on legacy VA layout mode by adjusting a sysctl knob vm.legacy_va_layout.

See: https://forums.unraid.net/topic/82110-mssql-docker-on-unraid/

@kspearrin
Copy link
Member

Maybe you are hitting these limits when backups run?

@evakq8r
Copy link
Author

evakq8r commented Aug 16, 2020

The backups had run once during the course of time this issue was opened, but I don't believe that to be the case. I had increased them to double what they are currently:

services:
  mssql:
   ulimits:
    stack:
     soft: "16384000"
     hard: "16384000"

That didn't make a difference with the error.

Is there any way to determine if that is actually the case though? (hitting the limits). The bitwarden-mssql container identifies 25716MB RAM during boot-up and the server itself has ~30TB of usable storage, so I don't believe the issue is physical RAM or storage.

@evakq8r
Copy link
Author

evakq8r commented Aug 24, 2020

Just an update on this. Backups have been running successfully in the container for the last 6 days, but in container only. Can't get them to route to the host without causing backups to fail.

Final setup:-

docker-compose.yaml:

version: '3'

services:
  mssql:
    image: bitwarden/mssql:1.36.1
    container_name: bitwarden-mssql
    restart: always
    stop_grace_period: 60s
    volumes:
      - mssql_data:/var/opt/mssql/data
      - mssql_data:/var/opt/mssql/log
      - mssql_data:/etc/bitwarden/mssql/backups
    env_file:
      - mssql.env
      - ../env/uid.env
      - ../env/mssql.override.env

docker-compose-override.yaml:

version: '3'

services:
  mssql:
    ulimits:
     stack:
      soft: "16384000"
      hard: "16384000"
      
networks:
  default:
    external:
      name: proxynet

The change in ulimit on its own didn't fix this unfortunately. It also required the mssql variables changed as well (each on their own caused backups to fail, for whatever reason both together allow the backups to work):

As seen below:

root@<mssql_container>:/etc/bitwarden/mssql/backups# ls -la

-rw-r----- 1 nobody nogroup   8118272 Aug 11 00:00 vault_FULL_20200811_000000.BAK
-rw-r----- 1 nobody nogroup   8118272 Aug 13 00:00 vault_FULL_20200813_000000.BAK
-rw-r----- 1 nobody nogroup   8118272 Aug 18 00:00 vault_FULL_20200818_000000.BAK
-rw-r----- 1 nobody nogroup   8118272 Aug 19 00:00 vault_FULL_20200819_000000.BAK
-rw-r----- 1 nobody nogroup   8118272 Aug 20 00:00 vault_FULL_20200820_000000.BAK
-rw-r----- 1 nobody nogroup   8118272 Aug 21 00:00 vault_FULL_20200821_000000.BAK
-rw-r----- 1 nobody nogroup   8118272 Aug 22 00:00 vault_FULL_20200822_000000.BAK
-rw-r----- 1 nobody nogroup   8118272 Aug 23 00:00 vault_FULL_20200823_000000.BAK
-rw-r----- 1 nobody nogroup   8118272 Aug 24 00:00 vault_FULL_20200824_000000.BAK

While I'd prefer the backups to point back to the host, this works and I'm no longer willing to break it. Closing ticket.

Thanks @kspearrin for your help with this.

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

3 participants