You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/developer/data-platform/scalable-customization-design/transaction-design-patterns.md
+30-33Lines changed: 30 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,23 @@
1
1
---
2
-
title: "Scalable Customization Design: Transaction design patterns (Microsoft Dataverse) | Microsoft Docs"# Intent and product brand in a unique string of 43-59 chars including spaces
3
-
description: "The fourth in a series of topics. "# 115-145 characters including spaces. This abstract displays in the search result.
4
-
ms.custom: ""
5
-
ms.date: 11/18/2018
6
-
ms.reviewer: "pehecke"
7
-
8
-
ms.topic: "article"
9
-
author: "rogergilchrist"# GitHub ID
10
-
ms.author: "jdaly"# MSFT alias of Microsoft employees only
> This is the fourth in a series of topics about scalable customization design. To start at the beginning, see [Scalable Customization Design in Microsoft Dataverse](overview.md).
20
17
21
18
This section describes design patterns to avoid or minimize and their implications. Each design pattern needs to be considered in the context of the business problem being solved and can be useful as options to investigate.
22
19
23
-
## Don’t avoid locking
20
+
## Don't avoid locking
24
21
25
22
Locking is a very important component of SQL Server and Dataverse, and is essential to healthy operation and consistency of the system. For this reason it is important to understand its implications on design, particularly at scale.
26
23
@@ -32,13 +29,13 @@ Views use this approach because there is no direct link between the act of launc
32
29
33
30
Because a query across a large data set means that it potentially affects others trying to interact with any of that data, being able to specify that no lock is required can have a significant benefit on system scalability.
34
31
35
-
When making a query of the platform through the SDK it can be valuable to specify that nolock can be used. It indicates that you recognize this query doesn’t need to take a read lock in the database. It’s especially useful for queries where:
32
+
When making a query of the platform through the SDK it can be valuable to specify that nolock can be used. It indicates that you recognize this query doesn't need to take a read lock in the database. It's especially useful for queries where:
36
33
37
-
- There’s a broad scope of data
34
+
- There's a broad scope of data
38
35
- Highly contested resources are queried
39
-
- Serialization isn’t important
36
+
- Serialization isn't important
40
37
41
-
Nolock shouldn’t be used if a later action depends on no change to the results, such as in the auto number locking example earlier.
38
+
Nolock shouldn't be used if a later action depends on no change to the results, such as in the auto number locking example earlier.
42
39
43
40
An example scenario where it can be useful is determining if an email is related to an existing case. Blocking other users from creating new cases to ensure there is no possibility of a case being generated that the email could link to would not be a beneficial level of consistency control.
44
41
@@ -69,7 +66,7 @@ In more complex and efficient scenarios, it may be that you lock least commonly
69
66
70
67
## Hold contentious locks for shortest period
71
68
72
-
There are scenarios, such as the auto numbering approach, where there is no way around the fact that there is a heavily contested resource that needs to be locked. In that case, the blocking problem can’t be completely avoided, but can be minimized.
69
+
There are scenarios, such as the auto numbering approach, where there is no way around the fact that there is a heavily contested resource that needs to be locked. In that case, the blocking problem can't be completely avoided, but can be minimized.
73
70
74
71
When you have heavily contested resources, a good design is to not include the interaction with that resource at the functionally logical point in the process, but move the interaction with it to as close to the end of the transaction as possible.
75
72
@@ -102,16 +99,16 @@ Review each query you make to determine whether:
102
99
- Your query only asks for what it needs, for example, columns, records, or entity types.
103
100
- This maximizes the chance that an index can be used to efficiently service the query
104
101
- It reduces the number of tables and resources that need to be accessed, reducing the overhead on other resources in the database server and reducing the query time
105
-
- It avoids potential blocking on resources that you don’t need, particularly where a join to another table is asked for but could be avoided or is unnecessary
102
+
- It avoids potential blocking on resources that you don't need, particularly where a join to another table is asked for but could be avoided or is unnecessary
106
103
- An index is in place to assist the query, you are querying in an efficient way, and an index seek rather than scan is taking place
107
104
108
-
It’s worth noting that introducing an index doesn’t avoid locking on create/update of records in the underlying table. The entries in the indexes are also locked when the related record is updated as the index itself is subject to change. The existence of indexes doesn’t avoid this problem completely.
105
+
It's worth noting that introducing an index doesn't avoid locking on create/update of records in the underlying table. The entries in the indexes are also locked when the related record is updated as the index itself is subject to change. The existence of indexes doesn't avoid this problem completely.
109
106
110
-
In the following example, the retrieval of related cases isn’t optimized and adds to the overall transaction length, introducing blocking between threads.
107
+
In the following example, the retrieval of related cases isn't optimized and adds to the overall transaction length, introducing blocking between threads.
111
108
112
109

113
110
114
-
By optimizing the query, there’s less time spent performing it, and the chance of collision is lower, thereby reducing blocking.
111
+
By optimizing the query, there's less time spent performing it, and the chance of collision is lower, thereby reducing blocking.
115
112
116
113

117
114
@@ -166,7 +163,7 @@ This is a pattern that should be carefully considered or avoided as it is very e
166
163
167
164
## When to use different types of customization
168
165
169
-
Each type of customization has different implications for use. The following table highlights some common patterns, when each should be considered and used, and when it isn’t appropriate for use.
166
+
Each type of customization has different implications for use. The following table highlights some common patterns, when each should be considered and used, and when it isn't appropriate for use.
170
167
171
168
Often a compromise between different behaviors may need to be considered so this gives guidance of some of the common characteristics and scenarios to consider but each scenario needs to be evaluated and the right approach chosen based on all the relevant factors.
172
169
@@ -175,12 +172,12 @@ Often a compromise between different behaviors may need to be considered so this
175
172
|Pre Validation|Sync|Plug-in|Short term validation of input values|Long running actions.<br /><br />When creating related items that should be rolled back if later steps fail.|
176
173
|Pre Operation|Sync|Workflow/Plug-in|Short term validation of input values.<br /><br />When creating related items that should be rolled back as part of platform step failure.|Long running actions.<br /><br />When creating an item and the resulting GUID will need to be stored against the item the platform step will create/update.|
177
174
|Post Operation |Sync|Workflow/ Plug-in|Short running actions that naturally follow the platform step and need to be rolled back if later steps fail, for example, creation of a task for the owner of a newly created account.<br /><br />Creation of related items that need the GUID of the created item and that should roll back the platform step in the event of failure|Long running actions.<br /><br />Where failure should not affect the completion of the platform pipeline step.|
178
-
|Not in event pipeline|Async|Workflow/ Plug-in|Medium length actions that would impact on the user experience.<br /><br />Actions that cannot be rolled back anyway in the event of failure.<br /><br />Actions that should not force the rollback of the platform step in the event of failure.|Very long running actions.<br /><br />These shouldn’t be managed in Dataverse.<br /><br />Very low cost actions. The overhead of generating async behavior for very low cost actions may be prohibitive; where possible do these synchronously and avoid the overhead of async processing.|
175
+
|Not in event pipeline|Async|Workflow/ Plug-in|Medium length actions that would impact on the user experience.<br /><br />Actions that cannot be rolled back anyway in the event of failure.<br /><br />Actions that should not force the rollback of the platform step in the event of failure.|Very long running actions.<br /><br />These shouldn't be managed in Dataverse.<br /><br />Very low cost actions. The overhead of generating async behavior for very low cost actions may be prohibitive; where possible do these synchronously and avoid the overhead of async processing.|
179
176
|N/A<br />Takes context of where it is called from||Custom Actions|Combinations of actions launched from an external source, for example, from a web resource|When always triggered in response to a platform event, use plug-in/workflow in those cases.|
Long running or volume actions aren’t intended to be run from plug-ins or workflows. Dataverse isn’t intended to be a compute platform and especially isn’t intended as the controller to drive big groups of unrelated updates.
180
+
Long running or volume actions aren't intended to be run from plug-ins or workflows. Dataverse isn't intended to be a compute platform and especially isn't intended as the controller to drive big groups of unrelated updates.
184
181
185
182
If you have a need to do that, offload and run from a separate service, such as an Azure worker role.
186
183
@@ -195,8 +192,8 @@ A very common escalation area is scalability of setting up security. This is a c
195
192
196
193
### Owner v. access teams
197
194
198
-
- If users' teams change regularly, be careful about using owner teams heavily; every time they change they invalidate the user’s cache in the web server
199
-
- Ideally make changes when the user isn’t working, reduce impact, such as overnight
195
+
- If users' teams change regularly, be careful about using owner teams heavily; every time they change they invalidate the user's cache in the web server
196
+
- Ideally make changes when the user isn't working, reduce impact, such as overnight
200
197
201
198
### Lots of team memberships/ BUs
202
199
@@ -208,22 +205,22 @@ A very common escalation area is scalability of setting up security. This is a c
208
205
209
206
### Careful updating of user records
210
207
211
-
- Don’t regularly update system user records unless something fundamental has changed as this forces the user cache to be reloaded and the security privileges to be recalculated, an expensive activity
212
-
- Don’t use system user to record how many open activities the user has, for example
208
+
- Don't regularly update system user records unless something fundamental has changed as this forces the user cache to be reloaded and the security privileges to be recalculated, an expensive activity
209
+
- Don't use system user to record how many open activities the user has, for example
213
210
214
211
## Diagram related actions
215
212
216
-
An activity that is very beneficial as a preventative measure, as well as a tool for diagnosing blocking problems, is to diagram related actions triggered in the Dataverse platform. When doing this it helps to highlight both intentional and unintentional dependencies and triggers in the system. If you aren’t able to do this for your solution, you might not have a clear picture of what your implementation actually does. Creating such a diagram can expose unintended consequences and is good practice at any time in an implementation.
213
+
An activity that is very beneficial as a preventative measure, as well as a tool for diagnosing blocking problems, is to diagram related actions triggered in the Dataverse platform. When doing this it helps to highlight both intentional and unintentional dependencies and triggers in the system. If you aren't able to do this for your solution, you might not have a clear picture of what your implementation actually does. Creating such a diagram can expose unintended consequences and is good practice at any time in an implementation.
217
214
218
215
The following example highlights how initially two processes work perfectly well together but in ongoing maintenance the addition of a new step to create a task can create an unintended loop. Using this documentation technique can highlight this at the design stage and avoid this affecting the system.
219
216
220
217

221
218
222
-
<!-- NOTE: Excluding content on isolation modes and transaction diagnosis as it is for on-premises only. -->
219
+
## Review telemetry and traces
223
220
224
-
## Review system captured statistics
221
+
You can set up an Application Insights environment to receive telemetry on diagnostics and performance captured by the Dataverse platform. [Learn how to analyze Dataverse telemetry with Application Insights](/power-platform/admin/analyze-telemetry)
225
222
226
-
There are a number of ways to determine what is happening if the problem occurs outside of the database layer. The first is analysis of plug-in performance. The [PluginTypeStatistic Entity](../reference/entities/plugintypestatistic.md) can be queried to give an indication of how often the plug-in is running, and statistics on how long it typically takes to run.
223
+
After you have an Application Insights environment, you can use the [Microsoft.Xrm.Sdk.PluginTelemetry.ILogger interface](xref:Microsoft.Xrm.Sdk.PluginTelemetry.ILogger) in your plug-in code to write telemetry to Application insights. [Learn how to write Telemetry to your Application Insights resource using ILogger](../application-insights-ilogger.md)
227
224
228
225
When certain errors are occurring, using the server trace files to understand where related problems may be occurring in the platform can also be useful. More information: [Use Tracing](../debug-plug-in.md#use-tracing)
229
226
@@ -242,7 +239,7 @@ Some key things to remember include the following:
242
239
243
240
- Platform constraints often exhibit in the form of errors
244
241
- But rarely is the constraint the cause of the problem
245
-
- They’re there to protect the platform and other activity from being affected
242
+
- They're there to protect the platform and other activity from being affected
0 commit comments