Skip to content

Commit

Permalink
0005016: SQL Server: make extract_request, table_reload_status,
Browse files Browse the repository at this point in the history
table_reload_request, and trigger_hist row level locking
  • Loading branch information
Philip Marzullo committed Jun 3, 2021
1 parent 2b55349 commit ed766e9
Showing 1 changed file with 38 additions and 2 deletions.
Expand Up @@ -112,15 +112,27 @@ protected boolean alterLockEscalation () {
+ tablePrefix.toLowerCase()
+ "_data_event', '"
+ tablePrefix.toLowerCase()
+ "_monitor_event') and (i.allow_row_locks !='true' "
+ "_monitor_event', '"
+ tablePrefix.toLowerCase()
+ "_table_reload_status', '"
+ tablePrefix.toLowerCase()
+ "_extract_request', '"
+ tablePrefix.toLowerCase()
+ "_table_reload_request', '"
+ tablePrefix.toLowerCase()
+ "_trigger_hist') 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";
String monitorEventTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix + "_monitor_event");
String tableReloadStatusTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix + "_table_reload_status");
String extractRequestTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix + "_extract_request");
String tableReloadRequestTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix + "_table_reload_request");
String triggerHistTable = platform.alterCaseToMatchDatabaseDefaultCase(tablePrefix + "_trigger_hist");

sqlTemplate.update("ALTER INDEX ALL ON " + dataTable
+ " SET (ALLOW_ROW_LOCKS = ON)");
Expand All @@ -130,6 +142,14 @@ protected boolean alterLockEscalation () {
+ " SET (ALLOW_ROW_LOCKS = ON)");
sqlTemplate.update("ALTER INDEX ALL ON " + monitorEventTable
+ " SET (ALLOW_ROW_LOCKS = ON)");
sqlTemplate.update("ALTER INDEX ALL ON " + tableReloadStatusTable
+ " SET (ALLOW_ROW_LOCKS = ON)");
sqlTemplate.update("ALTER INDEX ALL ON " + extractRequestTable
+ " SET (ALLOW_ROW_LOCKS = ON)");
sqlTemplate.update("ALTER INDEX ALL ON " + tableReloadRequestTable
+ " SET (ALLOW_ROW_LOCKS = ON)");
sqlTemplate.update("ALTER INDEX ALL ON " + triggerHistTable
+ " SET (ALLOW_ROW_LOCKS = ON)");

if (parameterService.is(ParameterConstants.MSSQL_LOCK_ESCALATION_DISABLED, true)) {
sqlTemplate.update("ALTER INDEX ALL ON " + dataTable
Expand All @@ -140,6 +160,14 @@ protected boolean alterLockEscalation () {
+ " SET (ALLOW_PAGE_LOCKS = OFF)");
sqlTemplate.update("ALTER INDEX ALL ON " + monitorEventTable
+ " SET (ALLOW_PAGE_LOCKS = OFF)");
sqlTemplate.update("ALTER INDEX ALL ON " + tableReloadStatusTable
+ " SET (ALLOW_PAGE_LOCKS = OFF)");
sqlTemplate.update("ALTER INDEX ALL ON " + extractRequestTable
+ " SET (ALLOW_PAGE_LOCKS = OFF)");
sqlTemplate.update("ALTER INDEX ALL ON " + tableReloadRequestTable
+ " SET (ALLOW_PAGE_LOCKS = OFF)");
sqlTemplate.update("ALTER INDEX ALL ON " + triggerHistTable
+ " SET (ALLOW_PAGE_LOCKS = OFF)");

sqlTemplate.update("ALTER TABLE " + dataTable
+ " SET (LOCK_ESCALATION = DISABLE)");
Expand All @@ -149,6 +177,14 @@ protected boolean alterLockEscalation () {
+ " SET (LOCK_ESCALATION = DISABLE)");
sqlTemplate.update("ALTER TABLE " + monitorEventTable
+ " SET (LOCK_ESCALATION = DISABLE)");
sqlTemplate.update("ALTER TABLE " + tableReloadStatusTable
+ " SET (LOCK_ESCALATION = DISABLE)");
sqlTemplate.update("ALTER TABLE " + extractRequestTable
+ " SET (LOCK_ESCALATION = DISABLE)");
sqlTemplate.update("ALTER TABLE " + tableReloadRequestTable
+ " SET (LOCK_ESCALATION = DISABLE)");
sqlTemplate.update("ALTER TABLE " + triggerHistTable
+ " SET (LOCK_ESCALATION = DISABLE)");
}
return true;
} else {
Expand Down

0 comments on commit ed766e9

Please sign in to comment.