Skip to content

Commit b840c88

Browse files
committed
revised
1 parent 75a6096 commit b840c88

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

powerapps-docs/developer/data-platform/scalable-customization-design/database-transactions.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
---
2-
title: "Scalable Customization Design: Database Transactions (Microsoft Dataverse) | Microsoft Docs" # Intent and product brand in a unique string of 43-59 chars including spaces
3-
description: "The second in a series of topics. This topic focuses on the impact of database transactions on scalable customization design" # 115-145 characters including spaces. This abstract displays in the search result.
4-
ms.custom: ""
5-
ms.date: 1/15/2019
6-
ms.reviewer: "pehecke"
7-
8-
ms.topic: "article"
9-
author: "rogergilchrist" # GitHub ID
10-
ms.author: "jdaly" # MSFT alias of Microsoft employees only
2+
title: "Scalable Customization Design: Database Transactions (Microsoft Dataverse) | Microsoft Docs"
3+
description: "The second in a series of topics. This topic focuses on the impact of database transactions on scalable customization design"
4+
ms.date: 06/23/2023
5+
ms.reviewer: pehecke
6+
ms.topic: article
7+
author: rogergilchrist
8+
ms.author: jdaly
119
search.audienceType:
1210
- developer
1311
---
14-
1512
# Scalable Customization Design: Database transactions
1613

17-
18-
1914
> [!NOTE]
2015
> This is the second in a series of topics about scalable customization design. To start at the beginning, see [Scalable Customization Design in Microsoft Dataverse](overview.md).
2116
@@ -31,20 +26,21 @@ One of the most fundamental concepts behind many of the challenges faced here is
3126
A common reason that problems can occur in this area is the lack of awareness of how customizations can affect transactions.
3227

3328
Although the details of how this is done is beyond the scope of this topic, the most simple element to consider is that as Dataverse interacts with data in its database. SQL Server determines the appropriate locks to be taken by transactions on that data such as:
29+
3430
- When creating a record, it generates a write lock against that record.
3531
- When updating a record, it takes a write lock against the record.
36-
- When a lock is taken against a table or record, its also taken against any corresponding index records.
32+
- When a lock is taken against a table or record, it's also taken against any corresponding index records.
3733

38-
However, its possible to influence the scope and duration of these locks. Its also possible to indicate to SQL Server that no lock is required for certain scenarios.
34+
However, it's possible to influence the scope and duration of these locks. It's also possible to indicate to SQL Server that no lock is required for certain scenarios.
3935

40-
Lets consider SQL Server database locking and the impact of separate requests trying to access the same data. In the following example, creating an account has set up a series of processes, some with plug-ins that are triggered as soon as the record is created, and some in a related asynchronous workflow that is initiated at creation.
36+
Let's consider SQL Server database locking and the impact of separate requests trying to access the same data. In the following example, creating an account has set up a series of processes, some with plug-ins that are triggered as soon as the record is created, and some in a related asynchronous workflow that is initiated at creation.
4137

4238
The example shows the consequences when an account update process has complex post processing while other activity also interacts with the same account record. If an asynchronous workflow is processed while the account update transaction is still in progress, this workflow could be blocked waiting to obtain an update lock to change the same account record, which is still locked.
4339

4440
![locking and transactions example.](media/locking-and-transactions-example.png)
4541

4642
It should be noted that transactions are only held within the lifetime of a particular request to the platform.
47-
Locks arent held at a user session level or while information is being shown in the user interface. As soon as the platform has completed the request, it releases the database connection, the related transaction, and any locks it has taken.
43+
Locks aren't held at a user session level or while information is being shown in the user interface. As soon as the platform has completed the request, it releases the database connection, the related transaction, and any locks it has taken.
4844

4945

5046
## Blocking
@@ -59,7 +55,7 @@ While the first request to grab the auto-number resource lock can easily be comp
5955

6056
## Lock release
6157

62-
There are two primary reasons why a lock isnt released but is held until the transaction is completed:
58+
There are two primary reasons why a lock isn't released but is held until the transaction is completed:
6359

6460
- The database server holds onto the lock for consistency in case the transaction will later make another request to update the data item.
6561
- The database server also has to allow for the fact that an error or abort command issued later can cause it to roll the entire transaction back, so it needs to hold onto the locks for the entire lifetime of the transaction to ensure consistency.
@@ -93,9 +89,9 @@ Before understanding how customizations interact with the platform, it is useful
9389

9490
|Operation|Description|
9591
|--|--|
96-
|Forms (Retrieve)|• More likely to have conflicts. An update lock will block anything else updating that record.|
92+
|Forms (Retrieve)|• Low impact on other uses.|
9793
|Create|&bull; Performs a create request through the platform<br />&bull; Low impact on other activities, as a new record nothing else blocking on it<br />&bull; Can potentially block locking queries to the whole table until it is complete.<br />&bull; Often can trigger related actions in customization which can have an impact.|
98-
|Update|&bull; Performs an update request through the platform.<br />&bull; More likely to have conflicts. An update lock will block anything else updating or reading that record. Also blocks anything taking a broad read lock on that table.<br />&bull; Often triggers other activities.<br />&bull; In some rare cases, an update lock can block a read lock. One example of where this can occur is when Dataverse metadata is being changed: Reads done by a Dataverse metadata change transaction will be blocked by update locks.|
94+
|Update|&bull; Performs an update request through the platform.<br />&bull; More likely to have conflicts. An update lock will block anything else updating that record.<br />&bull; Often triggers other activities.<br />&bull; In some rare cases, an update lock can block a read lock. One example of where this can occur is when Dataverse metadata is being changed: Reads done by a Dataverse metadata change transaction will be blocked by update locks.|
9995
|View (RetrieveMultiple)|&bull; Would think this would block lots of other activity.<br />&bull; Although poor query optimization can affect DB resource usage and possibly hit timeouts.|
10096

10197
## Event pipeline: platform step
@@ -106,7 +102,7 @@ When an event pipeline is initiated, a SQL transaction is created to include the
106102

107103
## Customization requests
108104

109-
Its also possible to participate in the platform initiated transaction within customizations. Each type of customization participates in transactions in a different way. The following sections will describe each in turn.
105+
It's also possible to participate in the platform initiated transaction within customizations. Each type of customization participates in transactions in a different way. The following sections will describe each in turn.
110106

111107
- [Sync plug-ins (pre or post operation: in transaction context)](#sync-plug-ins-pre-or-post-operation-in-transaction-context)
112108
- [Sync plug-ins (pre and post operation: in transaction context)](#sync-plug-ins-pre-and-post-operation-in-transaction-context)
@@ -141,15 +137,15 @@ A plug-in can also be registered to act outside of the platform transaction by b
141137
142138
![Sync plug-ins (**PreValidation**: outside transaction context).](media/sync-plug-ins-pre-validation-outside-transaction-context.png)
143139

144-
This scenario only applies when the **PreValidation** is called as the first stage of a pipeline event . Even though the plug-in is registered on the **PreValidation** stage, it is possible it will participate in a transaction as the next section describes. It cant be assumed that a **PreValidation** plug-in doesnt participate in a transaction, although it is possible to check from the execution context if this is the case.
140+
This scenario only applies when the **PreValidation** is called as the first stage of a pipeline event . Even though the plug-in is registered on the **PreValidation** stage, it is possible it will participate in a transaction as the next section describes. It can't be assumed that a **PreValidation** plug-in doesn't participate in a transaction, although it is possible to check from the execution context if this is the case.
145141

146142
### Sync plug-ins (**PreValidation**: in transaction context)
147143

148144
The related scenario occurs when a **PreValidation** plug-in is registered but the related pipeline event is triggered by message request from within an existing transaction.
149145

150146
As the following diagram shows, creating an account can cause a **PreValidation** plug-in to perform initially outside of a transaction when the initial create is performed. If, as part of the post plug-in, a message request is made to create a related child account because that second event pipeline is initiated from within the parent pipeline, it will participate in the same transaction.
151147

152-
In that case, the **PreValidation** plug-in will discover that a transaction already exists and so will participate in that transaction even though its registered on the **PreValidation** stage.
148+
In that case, the **PreValidation** plug-in will discover that a transaction already exists and so will participate in that transaction even though it's registered on the **PreValidation** stage.
153149

154150
![Sync plug-ins (**PreValidation**: in transaction context).](media/sync-plug-ins-pre-validation-in-transaction-context.png)
155151

@@ -160,7 +156,7 @@ As previously mentioned, the plug-in can check the execution context for the <xr
160156
A plug-in can also be registered to act asynchronously. In this case, the plug-in also acts outside of the platform transaction.
161157

162158
> [!NOTE]
163-
> The plug-in doesnt create its own transaction; each message request within the plug-in is acted upon independently.
159+
> The plug-in doesn't create its own transaction; each message request within the plug-in is acted upon independently.
164160
165161
![foo.](media/async-plug-ins.png)
166162

@@ -171,7 +167,7 @@ To summarize:
171167

172168
- Synchronous plug-ins typically participate in transactions.
173169
- Async plug-ins never participate in a platform transaction; each request is performed independently.
174-
- **PreValidation** plug-ins dont create a transaction but participate if one already exists.
170+
- **PreValidation** plug-ins don't create a transaction but participate if one already exists.
175171

176172
|Event|Stage name|Transaction does not yet exist|Transaction already exists|
177173
|--|--|--|--|
@@ -216,7 +212,7 @@ Custom actions can create their own transactions. This is a key feature. A custo
216212
- If called through a message request from a plug-in running within the transaction, and Enable Rollback is set, the custom action will act within the existing transaction.
217213
- The custom action will otherwise create a new transaction and run within that.
218214
- Enable Rollback not set
219-
- The custom action wont act within a transaction.
215+
- The custom action won't act within a transaction.
220216

221217
![custom actions.](media/custom-actions.png)
222218

0 commit comments

Comments
 (0)