问题
We have recently upgraded to Sonar 5.3 from 4.4.1 and seen duplicate key issue with one of our projects. I checked the collation and found database server and database to be case insensitive and column to be case sensitive. Should we change collation on the database to "Latin1_General_CS_AS" ? Changing the collation on the server is bit difficult but we can try with database.
SELECT SERVERPROPERTY('COLLATION')
Output: Latin1_General_CI_AS
SELECT DATABASEPROPERTYEX('<SonarDatabaseName>', 'Collation') SQLCollation;
Output: Latin1_General_CI_AS
For the column, it is "Laitn1_General_CS_AS"
Error in sonar log. I did see a duplicate key in the table but not sure if this is due to collation as reported here Duplicate key error with SonarQube 5.2:
ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVM28yZdM8YcgYQ_GJuI
org.sonar.server.computation.component.VisitException: Visit failed for Component
.
.
### Error updating database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert duplicate key row in object 'dbo.projects' with unique index 'projects_kee'.
Thanks in advance.
回答1:
Case sensitivity is a requirement, so yes you really need to change the collation of this database (putting it case-sensitive (CS) and accent-sensitive (AS)).
来源:https://stackoverflow.com/questions/35827598/duplicate-key-error-post-sonarqube-5-3-upgrade