{"title":"Tri-state locking in database","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-tri-state-locking/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-tri-state-locking, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-tri-state-locking","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn about the tri-state locking feature in Business Central.","date":"2025-09-29","meta":{"topic":"article"},"outline":[{"level":1,"title":"Tri-state locking in database","slug":"tri-state-locking-in-database","at":0,"chars":3662},{"level":2,"title":"Locking behavior","slug":"locking-behavior","at":640,"chars":1939},{"level":2,"title":"Enable and disable tri-state locking for a tenant","slug":"enable-and-disable-tri-state-locking-for-a-tenant","at":2579,"chars":989},{"level":2,"title":"Related information","slug":"related-information","at":3568,"chars":94}],"text":"# Tri-state locking in database\n> APPLIES TO: Business Central 2023 release wave 2 (version 23) and later\nThe tri-state locking feature is aimed at enhancing the performance and concurrency of database transactions. By enabling this feature, AL-based read operations that follow write operations are performed optimistically, rather than with strict consistency and low concurrency. So, users can expect higher levels of concurrency and fewer blocked or failed operations while accessing data.\n> NOTE\n> Explicitly using the methods-auto/record/record-locktable-method method in code maintains the same behavior, disabling optimistic reads.\n## Locking behavior\nThe Business Central server uses database locks on a table when a session starts to change data in the table. The following examples illustrate the legacy locking behavior, used in versions 22 and earlier, compared to tri-state locking.\n```al\n// locking behavior in versions 22 (and earlier)\ntrigger OnAction()\nvar\n    currency1: Record Currency;\n    currency2: Record Currency;\nbegin\n    currency1.FindFirst(); // SQL statement use READUNCOMMITTED\n\n    currency1.Code := 'DKK';\n    currency1.\"ISO Code\" := 'DKK';\n    currency1.Symbol := 'Kr';\n    currency1.Insert();\n\n    currency2.FindLast(); // SQL statement use UPDLOCK (so locks data with an exclusive lock)\nend;\n```\nContrast this behavior with how locks are taken with tri-state locking.\n```al\n// locking behaviour with tri-state locking\ntrigger OnAction()\nvar\n    currency1: Record Currency;\n    currency2: Record Currency;\nbegin\n    currency1.FindFirst(); // SQL statement use READUNCOMMITTED\n\n    currency1.Code := 'DKK';\n    currency1.\"ISO Code\" := 'DKK';\n    currency1.Symbol := 'Kr';\n    currency1.Insert();\n\n    currency2.FindLast(); // SQL statement use READCOMMITTED (so locks data with a shared lock)\nend;\n```\nIn both cases, the locking behavior is about what happens in a session after a record instance does a data modification (insert/update/delete) on a table.\nProperties|Locking behavior in versions 22 (and earlier)|Locking behavior with tri-state locking\nDefault isolation level for subsequent operations|UpdLock|ReadCommitted\nLocking behavior|Session would acquire update lock on data from the table until it committed or rolled back its changes.|Session only acquires a shared lock when reading data.\nConsequences|Could cause blocking and contention issues when multiple sessions tried to access or modify the same table.|Allows other sessions to read and write to the same table concurrently, if they don't conflict with each other's changes.\n## Enable and disable tri-state locking for a tenant\nTri-state locking is enabled by default for Business Central online and on-premises. If you prefer to use legacy locking, you can disable tri-state locking from the Feature Management page as follows:\n In version 25, set the Enabled for field for the Feature: Enable legacy locking scheme in AL to All users:\n In versions 24 and 23, set the Enabled for field for Feature: Enable tri-state locking in AL to None.\nChanges take effect on users the next time they sign in to Business Central. Learn more about feature management in Enabling Upcoming Features Ahead of Time<../administration/feature-management>.\n> NOTE\n> If you're using Business Central on-premises version 23, 24, or 25, the EnableTriStateLocking setting in the server configuration must also be set to true to use tri-state locking. Learn more about configuring the server<../administration/configure-server-instance>. Tri-state locking is always used in later versions.\n## Related information\nMonitoring SQL database locks<../administration/monitor-database-locks>"}