perf(deployment,template-engine): batched untracked staleness loads, staging-failure detach, lock-held Disabled re-check, targeted single-entity loads (DEP-4, DEP-5, DEP-6, TPL-4, WP6 task 6.6)
DEP-4: new ITemplateEngineRepository.GetInstancesByIdsUntrackedAsync (one
AsNoTracking split query per 500-id chunk). GetInstanceStalenessAsync preloads
each chunk into its FlattenSession; FlattenCoreAsync takes a preloaded
instance (consumed once) before falling back to the tracked per-instance load.
Deploy sessions never preload, so prepare keeps its tracked load.
Throwaway harness, SQLite, 1,000 instances x 50 overrides:
before: 5,000 reader commands, 51,000 tracked entities
after: 10 reader commands, 0 tracked entities
(wall time on in-process SQLite 2.7 s -> 2.3 s; the win on SQL Server is
the 4,990 saved round-trips and the change tracker staying empty)
DEP-5: AddPendingDeploymentAsync supersedes prior rows with a set-based
delete (DeletePendingWhereAsync) instead of tracked key stubs, and a failed
staging save calls DetachPendingChanges under dbGate so it cannot poison the
next instance's staging save on the shared bulk context.
Regression: prior row purged between supersede and save -> before:
DbUpdateConcurrencyException; after: stages cleanly.
DEP-6: bulk prepare (reconcileGate != null) re-reads the instance state
untracked (new IDeploymentManagerRepository.GetInstanceStateAsync) once the
operation lock is held; Disabled -> reported in SkippedInstances with the
Disabled reason, never flattened/sent/re-enabled. Placed at the top of
PrepareUnderLockAsync so it is independent of WP7's lock-ordering change.
TPL-4: area delete uses the new shallow untracked GetInstancesBySiteIdShallowAsync;
SetAlarmOverride and Delete{Attribute,Alarm,Script} read the analysis closure
instead of the whole template table; MoveTemplate's collision check is the new
TemplateNameExistsInFolderAsync (one folder's names). SiteService already used
the include-free ISiteRepository read (unchanged).
This commit is contained in:
@@ -180,6 +180,14 @@ site-wide push would silently restart every piece of equipment an operator had
|
||||
deliberately stopped; they are reported in the summary's `SkippedInstances` with
|
||||
the reason "Disabled — bulk deploy preserves disabled state; deploy individually
|
||||
to re-enable", and the single-instance deploy remains the explicit re-enable path.
|
||||
The skip is re-checked once each instance's operation lock is held (DEP-6, 2026-12-03):
|
||||
the candidate list is read once when the batch starts, so an instance an operator
|
||||
disables while the batch is still preparing earlier instances is caught by a fresh,
|
||||
untracked state read (`IDeploymentManagerRepository.GetInstanceStateAsync`) and reported
|
||||
as skipped with the same reason, instead of being deployed and re-enabled. A failed
|
||||
staging write detaches its pending changes so it cannot poison the staging writes of
|
||||
the instances after it on the shared unit of work (DEP-5), and the supersede of a prior
|
||||
`PendingDeployment` row is a set-based delete rather than tracked key stubs.
|
||||
|
||||
**Up-to-date instances are skipped too (unless `force`), at batch cost.** The
|
||||
pre-filter reads the deployed-hash projection (`GetDeployedRevisionHashesAsync`) and
|
||||
|
||||
Reference in New Issue
Block a user