{"title":"Analyzing database lock timeout trace telemetry","url":"https://jonas-paprotka.de/docs/dev-itpro/administration/telemetry-database-locks-trace/","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/administration/telemetry-database-locks-trace, 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/administration/telemetry-database-locks-trace","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":"Analyze database lock timeout telemetry in Business Central and correlate lock snapshots to identify blocked sessions and troubleshoot database contention.","date":"2026-11-17","meta":{"topic":"concept-article"},"outline":[{"level":1,"title":"Analyzing database lock timeout trace telemetry","slug":"analyzing-database-lock-timeout-trace-telemetry","at":0,"chars":13611},{"level":2,"title":"Database lock timed out","slug":"database-lock-timed-out","at":1563,"chars":3781},{"level":3,"title":"General dimensions","slug":"general-dimensions","at":1647,"chars":102},{"level":3,"title":"Custom dimensions","slug":"custom-dimensions","at":1749,"chars":2229},{"level":3,"title":"Sample KQL code","slug":"sample-kql-code","at":3978,"chars":1366},{"level":2,"title":"Database lock snapshot (entry)","slug":"database-lock-snapshot-entry","at":5344,"chars":4729},{"level":3,"title":"General dimensions","slug":"general-dimensions-1","at":5852,"chars":121},{"level":3,"title":"Custom dimensions","slug":"custom-dimensions-1","at":5973,"chars":2715},{"level":3,"title":"Sample KQL code","slug":"sample-kql-code-1","at":8688,"chars":1385},{"level":2,"title":"Database lock snapshot (parent)","slug":"database-lock-snapshot-parent","at":10073,"chars":2492},{"level":3,"title":"General dimensions","slug":"general-dimensions-2","at":10365,"chars":130},{"level":3,"title":"Custom dimensions","slug":"custom-dimensions-2","at":10495,"chars":1605},{"level":3,"title":"Sample KQL code","slug":"sample-kql-code-2","at":12100,"chars":465},{"level":2,"title":"Troubleshooting locking issues with telemetry","slug":"troubleshooting-locking-issues-with-telemetry","at":12565,"chars":881},{"level":2,"title":"Related information","slug":"related-information","at":13446,"chars":165}],"text":"# Analyzing database lock timeout trace telemetry\nINTRODUCED IN: Business Central 2020 release wave 1, version 16.0\nDatabase lock timeout telemetry gathers information about database locks that have timed out. The telemetry data allows you to troubleshoot what caused these locks.\nIn the client, when a lock has timed out, the user is presented with a message, similar to the following message:\n*The operation could not complete because a record in the [table name] table was locked by another user. Please retry the activity.*\nTwo types of trace events are emitted to Application Insights:\n The first is a Database lock timed out event. This event includes general information about the lock request. This event includes information like the AL object and code that is impacted by the lock, the extension involved, and more.\n The Database lock timed out event then triggers one or more Database lock snapshot events. Database lock snapshot events provide details about SQL sessions that hold database locks at the time of lock timeout, including the session that caused the lock timeout. These events include specific details about the SQL lock request on the database, like the type, status, mode, and the table.\n> NOTE\n> In later versions of Business Central on-premises, the Business Central Server includes the EnableLockTimeoutMonitoring setting. Use this setting to turn database lock timeout telemetry on or off. By default, it is off. See Configuring Business Central Server<server-instance-settings#detect-database-contention-and-long-running-queries>.\n## Database lock timed out\nOccurs when a database lock has timed out for a session.\n### General dimensions\nDimension|Description or value\nmessage|Database lock timed out\nseverityLevel|3\n### Custom dimensions\nDimension|Description or value\naadTenantId|Specifies the Microsoft Entra tenant ID used for Microsoft Entra authentication. For on-premises, if you aren't using Microsoft Entra authentication, this value is common.\nalObjectId|Specifies the ID of the running AL object that requested the lock.\nalObjectName|Specifies the name of the running AL object that requested the lock.\nalObjectType|Specifies the type of the running AL object that requested the lock, such as a page or report.\nalStackTrace|The stack trace in AL.\nclientType|Specifies the type of client that executed the SQL statement, such as Background or WebClient. See ClientType option type<../developer/methods-auto/clienttype/clienttype-option>.\ncompanyName|Specifies the display name of the Business Central company.\ncomponent|Dynamics 365 Business Central Server\ncomponentVersion|Specifies the version number of the component that emits telemetry (see the component dimension.)\ndeprecatedKeys|Specifies a comma-separated list of all the keys that have been deprecated. The keys in this list are still supported but will eventually be removed in the next major release. We recommend that you update any queries that use these keys to use the new key name.\neventId|RT0012\nenvironmentName|Specifies the name of the tenant environment. See Managing environments<tenant-admin-center-environments>.\nenvironmentType|Specifies the environment type for the tenant, such as Production, Sandbox, Trial. See tenant-admin-center-environments#types-of-environments.\nextensionId|Specifies the AppID of the extension that was involved in the lock.\nextensionName|Specifies the name of the extension that was involved in the lock.\nextensionVersion|Specifies the version of the extension that was involved in the lock.\nsessionId|Specifies the ID of the session that requested the lock.\nsnapshotId|Specifies the ID of the database snapshot. This ID is used to identify associated Database lock snapshot trace events.\nsqlServerSessionId|Specifies the ID of the SQL server session that requested the lock.\nsqlStatement|Specifies the SQL statement whose lock request timed out.\ntelemetrySchemaVersion|Specifies the version of the Business Central telemetry schema.\n### Sample KQL code\nThis KQL code can help you get started troubleshooting lock timeouts.\n> NOTE\n> If these events aren't available on-premises, check whether EnableLockTimeoutMonitoring is enabled. See #analyzing-database-lock-timeout-trace-telemetry.\n```kql\ntraces\n| where timestamp > ago(2d) // adjust to your needs\n| where customDimensions has 'RT0012'\n| where customDimensions.eventId == 'RT0012'\n| project timestamp\n, aadTenantId = customDimensions.aadTenantId\n, environmentType = customDimensions.environmentType\n, environmentName = customDimensions.environmentName\n, companyName = customDimensions.companyName\n, clientType = customDimensions.clientType\n, alObjectId = customDimensions.alObjectId\n, alObjectType = customDimensions.alObjectType\n, alObjectName = customDimensions.alObjectName\n, extensionVersion = customDimensions.extensionVersion\n, extensionName = customDimensions.extensionName\n, extensionId = customDimensions.extensionId\n, alStackTrace = customDimensions.alStackTrace\n, sqlStatement = customDimensions.sqlStatement\n, sqlServerSessionId = customDimensions.sqlServerSessionId\n, snapshotId = customDimensions.snapshotId\n, sessionId = customDimensions.sessionId\n, usertelemetryId = case(\n  // usertelemetryId was introduced in the platform in version 20.0\n  toint( substring(customDimensions.componentVersion,0,2)) >= 20, user_Id\n, 'N/A'\n)\n```\n## Database lock snapshot (entry)\nThis telemetry event can occur in two ways:\n1. When a database lock has timed out\n1. When a user or AL process has requested that a snapshot is taken\nIn the case of a database lock timeout, the BC server also takes a snapshot. Here, the Database lock snapshot trace event is associated with a specific Database lock timed out trace event. The value of the `{snapshotId}` maps to the snapshotId dimension of the Database lock timed out trace event that triggered this event.\n### General dimensions\nDimension|Description or value\nmessage|Database lock snapshot entry: {snapshotId}\nseverityLevel|3\n### Custom dimensions\nDimension|Description or value\naadTenantId|Specifies the Microsoft Entra tenant ID used for Microsoft Entra authentication. For on-premises, if you aren't using Microsoft Entra authentication, this value is common.\nalObjectId|Specifies the ID of the running AL object that requested the lock.\nalObjectName|Specifies the name of the running AL object that requested the lock.\nalObjectType|Specifies the type of the running AL object that requested the lock, such as a page or report.\nalStackTrace|The stack trace in AL.\ncomponent|Dynamics 365 Business Central Server\ncomponentVersion|Specifies the version number of the component that emits telemetry (see the component dimension.)\ndeprecatedKeys|Specifies a comma-separated list of all the keys that have been deprecated. The keys in this list are still supported but will eventually be removed in the next major release. We recommend that you update any queries that use these keys to use the new key name.\neventId|RT0013\nenvironmentName|Specifies the name of the tenant environment. See Managing environments<tenant-admin-center-environments>.\nenvironmentType|Specifies the environment type for the tenant, such as Production, Sandbox, Trial. See tenant-admin-center-environments#types-of-environments.\nextensionId|Specifies the AppID of the extension that was involved in the lock.\nextensionName|Specifies the name of the extension that was involved in the lock.\nextensionVersion|Specifies the version of the extension that was involved in the lock.\nsessionId|Specifies the ID of the session that requested the lock.\nsnapshotId|Specifies the ID of the database snapshot. All messages in the snapshot share this ID.\nsqlLockRequestMode|Specifies the lock mode that determines how concurrent transactions can access the resource. See Lock Modes<https://learn.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms175519(v=sql.105)>.\nsqlLockRequestStatus|Specifies the current status of the lock, which can be one of the following values:<ul><li>CNVRT - means that the lock is transitioning from another mode, but the conversion is blocked by another process that holds a lock with a conflicting mode.</li><li>GRANT - means that the lock is active.</li><li>WAIT- means that the lock is blocked by another process that holds a lock with a conflicting mode.</li></ul>\nsqlLockResourceType|Specifies the database resource affected by the lock. For example, DATABASE, FILE, OBJECT, PAGE, KEY, and more.\nsqlServerSessionId|Specifies the ID of the SQL server session that requested the lock.\nsqlTableName|Specifies the name of table on which the lock was held.\ntelemetrySchemaVersion|Specifies the version of the Business Central telemetry schema.\n### Sample KQL code\nThis KQL code can help you get started analyzing database lock snapshots:\n```kql\ntraces\n| where timestamp > ago(2d) // adjust to your needs\n| where customDimensions has 'RT0013'\n| where customDimensions.eventId == 'RT0013'\n| project timestamp\n, aadTenantId = customDimensions.aadTenantId\n, environmentType = customDimensions.environmentType\n, environmentName = customDimensions.environmentName\n, companyName = customDimensions.companyName\n, snapshotId = customDimensions.snapshotId\n, clientTypeHoldingLock = customDimensions.clientType\n, alObjectTypeHoldingLock = customDimensions.alObjectType\n, alObjectIdHoldingLock = customDimensions.alObjectId\n, alObjectNameHoldingLock = customDimensions.alObjectName\n, alStackTraceHoldingLock = customDimensions.alStackTrace\n, extensionNameHoldingLock = customDimensions.extensionName\n, extensionIdHoldingLock = customDimensions.extensionId\n, extensionVersionHoldingLock = customDimensions.extensionVersion\n, extensionPublisherHoldingLock = customDimensions.extensionPublisher\n, sqlTableLocked = customDimensions.sqlTableName\n, sqlLockResourceType = customDimensions.sqlLockResourceType\n, sqlLockRequestMode = customDimensions.sqlLockRequestMode\n, sqlLockRequestStatus = customDimensions.sqlLockRequestStatus\n, sqlServerSessionId = customDimensions.sqlServerSessionId\n, alSessionIdHoldingLock = customDimensions.sessionId\n```\n## Database lock snapshot (parent)\nOccurs when a database lock snapshot is taken to capture the current locking state. This event is emitted as a header/parent event that groups related lock snapshot entries (RT0013).\nAPPLIES TO: Business Central 2022 release wave 1, version 20.0, and later\n### General dimensions\nDimension|Description or value\nmessage|Database locks snapshot taken: {snapshotId}\nseverityLevel|3 (Error)\n### Custom dimensions\nDimension|Description or value\naadTenantId|Specifies the Microsoft Entra tenant ID used for Microsoft Entra authentication. For on-premises, if you aren't using Microsoft Entra authentication, this value is common.\nalObjectId|Specifies the ID of the AL object that requested the lock snapshot.\nalObjectName|Specifies the name of the AL object that requested the lock snapshot.\nalObjectType|Specifies the type of the AL object that requested the lock snapshot.\nclientType|Specifies the type of client that opened the session, such as Background or Web. For a list of the client types, see ClientType Option Type<../developer/methods-auto/clienttype/clienttype-option>.\ncompanyName|The current company name.\ncomponent|Dynamics 365 Business Central Server\ncomponentVersion|Specifies the version number of the component that emits telemetry.\nenvironmentName|Specifies the name of the tenant environment. See Managing Environments<tenant-admin-center-environments>.\nenvironmentType|Specifies the environment type for the tenant, such as Production or Sandbox. See tenant-admin-center-environments#types-of-environments.\neventId|RT0027\nextensionId|Specifies the AppID of the extension that contains the AL object.\nextensionName|Specifies the name of the extension that contains the AL object.\nextensionPublisher|Specifies the publisher of the extension that contains the AL object.\nextensionVersion|Specifies the version of the extension that contains the AL object.\nsnapshotId|Specifies the unique GUID for the lock snapshot. Use this ID to correlate with lock snapshot entries (RT0013).\n### Sample KQL code\n```kql\ntraces\n| where timestamp > ago(60d)\n| where customDimensions.eventId == 'RT0027'\n| project timestamp\n, message\n, aadTenantId = customDimensions.aadTenantId\n, environmentName = customDimensions.environmentName\n, companyName = customDimensions.companyName\n, snapshotId = customDimensions.snapshotId\n, alObjectId = customDimensions.alObjectId\n, alObjectName = customDimensions.alObjectName\n, alObjectType = customDimensions.alObjectType\n```\n## Troubleshooting locking issues with telemetry\nThe telemetry you see for lock timeouts only represents the session that is the victim in a locking issue, not the sessions that hold the locks. When analyzing database lock timeout telemetry, it's therefore useful to look at combined data from the Database lock timed out event and Database lock snapshot events. You might be lucky that the snapshot has captured information from locks that were held when the lock timeout occurred.\nYou can combine data from different events by using joins in your Kusto queries. See https://github.com/microsoft/BCTech/blob/master/samples/AppInsights/KQL/Queries/ExampleQueriesForEachArea/LockTimeouts.kql in the `Microsoft/BCTech` repository on GitHub. See Joins in Azure Monitor log queries<https://learn.microsoft.com/azure/azure-monitor/log-query/joins> in the Microsoft Azure documentation.\n## Related information\nMonitoring and Analyzing Telemetry<telemetry-overview>\nEnable Sending Telemetry to Application Insights<telemetry-enable-application-insights>"}