Files
DP44/docs/ai/Common/DTS.Common.Import/DatabaseLocks.md
2026-04-17 14:55:32 -04:00

2.9 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.Common.Import/DatabaseLocks/LockImportGroups.cs
Common/DTS.Common.Import/DatabaseLocks/LockImportTestSetups.cs
Common/DTS.Common.Import/DatabaseLocks/LockImportSensors.cs
2026-04-17T15:39:02.672881+00:00 zai-org/GLM-5-FP8 1 2421f56d39216d6a

Documentation: DTS.Common.Import.DatabaseLocks

1. Purpose

This module provides database locking mechanisms for import operations, ensuring that concurrent imports do not conflict by acquiring locks on Groups, TestSetups, and Sensors before import proceeds. It implements the ILockImport interface across three classes—LockImportGroups, LockImportTestSetups, and LockImportSensors—each managing locks for a specific entity type. The module handles lock acquisition, detection of contended locks (locks held by other users), automatic reclamation of expired "stranded" locks, and privileged lock stealing by administrators. All three classes reference FB 36740 in their namespace comments, suggesting they were created to address a specific feature request or bug fix.


2. Public Interface

Interface: ILockImport (from DTS.Common.Import.Interfaces)

All three classes implement this interface with the following members:

bool Contended { get; }

Returns true if any items could not be locked because another user holds the lock.

void FreeLock(ref ImportObject importObject)

Releases all locks currently held by this instance. Iterates through the internal locked items list and calls LockManager.FreeLock for each. The importObject parameter is passed by reference but is not used in the implementation.

void SetLock(ref ImportObject importObject, ref StringBuilder message)

Attempts to acquire locks on all relevant items from the importObject. Populates the message StringBuilder with details of any contended items. Clears internal lock tracking lists at the start of execution.

bool StealLock(bool proceed)

Attempts to forcibly acquire contended locks. Returns true if no contention exists or if locks were successfully stolen; false if the user lacks admin privileges or proceed is false.


Class: LockImportGroups

Constructor:

public LockImportGroups(User currentUser, double strandedLockTimeoutMinutes)

Behavior:

  • Locks items from importObject.StaticGroups()
  • Uses LockManager.ItemCategories.Group for lock operations
  • Tracks locks in _lockedGroups (successful) and _contendedGroups (failed due to contention)
  • Uses StringResources.ImportTestSetup_GroupsLocked for contention messages

Class: LockImportTestSetups

Constructor:

public LockImportTestSetups(User currentUser, double strandedLockTimeoutMinutes)

Behavior:

  • Locks items from importObject.TestSetups()
  • Uses LockManager.ItemCategories.TestSetup for initial lock attempts
  • Tracks locks in _lockedTests (