mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-07 01:46:53 +01:00
TCOG
This commit is contained in:
parent
4119417ce4
commit
45d8a6de32
3 changed files with 155 additions and 0 deletions
22
custom/knowledge/performance/pure-reads-set-readisolation.md
Normal file
22
custom/knowledge/performance/pure-reads-set-readisolation.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
bc-version: [all]
|
||||
domain: performance
|
||||
keywords: [readisolation, readuncommitted, pure-read, get, findset, findfirst, findlast]
|
||||
technologies: [al]
|
||||
countries: [w1]
|
||||
application-area: [all]
|
||||
---
|
||||
|
||||
# Set ReadIsolation explicitly on pure reads
|
||||
|
||||
## Description
|
||||
|
||||
In tCOG apps, pure reads should set an explicit `ReadIsolation` on the record instance before the read operation. This makes the read semantics intentional instead of inheriting whatever isolation level happens to be active in the surrounding transaction or caller. For display, lookup, and calculation helpers that only read data and do not make decisions that require committed consistency, the default convention is `IsolationLevel::ReadUncommitted`.
|
||||
|
||||
## Best Practice
|
||||
|
||||
Before a pure read such as `Get`, `FindSet`, `FindFirst`, `FindLast`, or a read-only existence or aggregation call, set `Rec.ReadIsolation(IsolationLevel::ReadUncommitted);` on the specific record instance, then perform the read. Use a stronger isolation level only when the procedure's functional contract requires committed or repeatable data.
|
||||
|
||||
## Anti Pattern
|
||||
|
||||
A read-only helper performs `Get`, `FindSet`, or another pure read without setting `ReadIsolation` on the record variable first. The code works, but the locking and consistency behavior is left implicit and can drift with surrounding transaction context. On hot paths such as page calculations, lookups, and repeated helper calls, this creates inconsistent conventions and makes concurrency behavior harder to reason about.
|
||||
Loading…
Add table
Add a link
Reference in a new issue