Skip to content

Commit

Permalink
0003323: sym_monitor_event should be row level locked on SQL Server
Browse files Browse the repository at this point in the history
  • Loading branch information
klementinastojanovska committed Dec 22, 2017
1 parent 91101e0 commit f46dbe5
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -113,21 +113,26 @@ protected boolean alterLockEscalation () {
+ tablePrefix.toLowerCase()
+ "_data', '"
+ tablePrefix.toLowerCase()
+ "_data_event') and (i.allow_row_locks !='true' "
+ "_data_event', '"
+ tablePrefix.toLowerCase()
+ "_monitor_event') and (i.allow_row_locks !='true' "
+ lockEscalationClause
+ ")") > 0) {
log.info("Updating indexes to prevent lock escalation");

String dataTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix + "_data");
String dataEventTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix + "_data_event");
String outgoingBatchTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix + "_outgoing_batch");
String monitorEventTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix) + "_monitor_event";

sqlTemplate.update("ALTER INDEX ALL ON " + dataTable
+ " SET (ALLOW_ROW_LOCKS = ON)");
sqlTemplate.update("ALTER INDEX ALL ON " + dataEventTable
+ " SET (ALLOW_ROW_LOCKS = ON)");
sqlTemplate.update("ALTER INDEX ALL ON " + outgoingBatchTable
+ " SET (ALLOW_ROW_LOCKS = ON)");
sqlTemplate.update("ALTER INDEX ALL ON " + monitorEventTable
+ " SET (ALLOW_ROW_LOCKS = ON)");

if (parameterService.is(ParameterConstants.MSSQL_LOCK_ESCALATION_DISABLED, true)) {
sqlTemplate.update("ALTER INDEX ALL ON " + dataTable
Expand All @@ -136,13 +141,17 @@ protected boolean alterLockEscalation () {
+ " SET (ALLOW_PAGE_LOCKS = OFF)");
sqlTemplate.update("ALTER INDEX ALL ON " + outgoingBatchTable
+ " SET (ALLOW_PAGE_LOCKS = OFF)");
sqlTemplate.update("ALTER INDEX ALL ON " + monitorEventTable
+ " SET (ALLOW_PAGE_LOCKS = OFF)");

sqlTemplate.update("ALTER TABLE " + dataTable
+ " SET (LOCK_ESCALATION = DISABLE)");
sqlTemplate.update("ALTER TABLE " + dataEventTable
+ " SET (LOCK_ESCALATION = DISABLE)");
sqlTemplate.update("ALTER TABLE " + outgoingBatchTable
+ " SET (LOCK_ESCALATION = DISABLE)");
sqlTemplate.update("ALTER TABLE " + monitorEventTable
+ " SET (LOCK_ESCALATION = DISABLE)");
}
return true;
} else {
Expand Down

0 comments on commit f46dbe5

Please sign in to comment.