HangfireIO / HangfireIO/Hangfire
Hangfire fails to create tables on specific collation.
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
# Versions
Hangfire version: 1.7.28
Storage: Hangfire.SqlServer 1.7.28
Docker desktop version: Docker Desktop 4.8.2 (79419)
# To Reproduce
When using the following docker-compose.yaml to host the database:
```yml
version: '3.8'
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-CU11-ubuntu-20.04
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: ""
MSSQL_COLLATION: "Latin1_General_100_BIN2_UTF8"
ports:
- 1433:1433
volumes:
- mssql:/var/opt/mssql
networks:
- mynetwork
volumes:
mssql:
networks:
mynetwork:
```
Hangfire will fail to create tables on a database created on the server.
The error comes from a sql error and can be reproduced by connecting to the database and running the following subset of the commands from:
https://github.com/HangfireIO/Hangfire/blob/v1.7.28/src/Hangfire.SqlServer/Install.sql
```sql
--FIRST RUN THIS
CREATE DATABASE HangfireTest;
-- THEN RUN THIS SNIPPET FROM Install.sql
USE HangfireTest;
BEGIN TRANSACTION
DECLARE @SchemaLockResult INT;
EXEC @SchemaLockResult = sp_getapplock @Resource = 'myschema:SchemaLock', @LockMode = 'Exclusive'
COMMIT TRANSACTION;
```
This will result in the following error:
```plain
Msg 17750, Level 16, State 0, Procedure sys.xp_userlock, Line 1 [Batch Start Line 5]
Could not load the DLL (server internal), or one of the DLLs it references. Reason: 126(The specified module could not be found.).
The 'sp_getapplock' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.
Completion time: 2022-05-20T13:27:51.4674102+02:00
```
If the line `MSSQL_COLLATION: "Latin1_General_100_BIN2_UTF8"` is removed from the docker-compose file it will complete without error.
# Expected behavior
That the Hangfire table installation can run on the specified translation.
# Known work around
Don't set the database collation on server level but on each individual database that needs it.
Contributor guide
Research direction
Start with src/Hangfire.SqlServer/Install.sql and reproduce the failure using the provided docker-compose.yaml and MSSQL_COLLATION setting. Run the sp_getapplock snippet against the created database, then determine whether Hangfire can address the collation-specific failure. Done means installation succeeds with this collation or the limitation is documented clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, docker-compose, sql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100