5.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T02:40:09.269029+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | ee1fc4660f405448 |
Locking
Purpose
This module defines core data structures for representing and handling locking state and errors within the DTS system. Specifically, LockRecord encapsulates the metadata of an active lock (e.g., who holds it, when it was created, and what resource it pertains to), while LockError provides a structured way to represent lock-related error conditions—including recoverable states like lock theft or loss—enabling callers to programmatically respond to specific failure modes. Together, they serve as the foundational data models for a locking service, likely used in distributed or multi-user scenarios where resource contention must be managed.
Public Interface
LockRecord
A read-only data class representing the state of a lock.
-
Constructor:
public LockRecord(string user, string machine, DateTime createTime, DateTime lastUpdate, string itemKey, int itemCategory, int itemId)Initializes a new instance with the specified lock metadata. All properties are set once at construction and immutable thereafter.
-
Properties:
string LockingUserName– The username of the entity holding the lock.string LockingMachineName– The machine name of the entity holding the lock.DateTime CreationTime– Timestamp when the lock was first acquired.DateTime LastUpdated– Timestamp of the last lock maintenance (e.g., heartbeat or renewal).string ItemKey– A string-based identifier for the locked item (e.g., a unique key or path).int ItemCategory– An integer category code (corresponding toLockCategoriesin the database) classifying the type of item being locked.int ItemId– A numeric identifier for the locked item (likely a primary key in a database table).
LockError
A read-only data class representing an error condition in lock operations.
-
Constructor:
public LockError(int error, string message, string user = null, string machine = null)Initializes a new instance with an error code, descriptive message, and optional context about the locking user/machine.
-
Properties:
int ErrorCode– The numeric error code (read-only after construction).string Message– Human-readable error description (read-only after construction).string LockingUser– Username associated with the error (defaults tostring.Emptyifnull).string LockingMachine– Machine name associated with the error (defaults tostring.Emptyifnull).bool LockStolen–trueifErrorCode == LOCKSTOLEN_ERROR(i.e.,998).bool LockLost–trueifErrorCode == LOCKDOESNTEXIST_ERROR(i.e.,997).
-
Constants:
BAD_NETPATH_ERROR = 994– Network path error (e.g., lost remote DB connection).SEM_TIMEOUT_ERROR = 995– Semaphore timeout (e.g., connection failure).ITEM_NOT_FOUND = 996– Referenced item does not exist.LOCKDOESNTEXIST_ERROR = 997– Lock record no longer exists (e.g., expired or deleted).LOCKSTOLEN_ERROR = 998– Lock was forcibly released by another party.UNKNOWN_ERROR = 999– Generic/unspecified error.
Invariants
LockRecordinstances are immutable after construction: all properties arereadonly(via auto-properties withprivate setimplied by lack of setters) and initialized only in the constructor.LockError.ErrorCode,Message,LockingUser, andLockingMachineare immutable after construction (viaprivate set).LockingUserandLockingMachineinLockErrorare nevernull; ifnullis passed to the constructor, they default tostring.Empty.LockStolenandLockLostare derived solely fromErrorCodeand are guaranteed to be consistent with the defined constants.
Dependencies
- Internal dependencies:
System(forDateTime,string,object, etc.).System.Data(imported but unused in these files; may indicate legacy or future use).
- External dependencies (inferred):
- Likely consumed by other modules in
DTS.CommonCore(e.g., a locking service or database persistence layer). ItemCategorysuggests integration with a database-definedLockCategoriestable (not present in source, but referenced in XML doc).- Error constants (
994–999) imply coupling to SQL Server or ADO.NET error handling (per comments referencingSqlClient).
- Likely consumed by other modules in
Gotchas
System.Dataimport is unused: Theusing System.Data;statement inLockRecord.csserves no purpose in the current implementation and may be legacy or placeholder.LockingUser/LockingMachinenull-safety: WhileLockErrorconstructor normalizesnullinputs tostring.Empty, callers must be aware thatnullis not preserved—this may mask missing context if not handled explicitly.- No validation in constructor: Neither
LockRecordnorLockErrorvalidates inputs (e.g., empty strings, negativeItemId/ItemCategory). Callers must ensure data integrity externally. LockLostvs.LockStolensemantics: The distinction betweenLOCKDOESNTEXIST_ERROR(LockLost) andLOCKSTOLEN_ERROR(LockStolen) is subtle:LockLostimplies the lock vanished without explicit release (e.g., timeout, crash).LockStolenimplies another party intentionally released the lock (e.g., admin override).
This distinction may be critical for retry or conflict-resolution logic but is not enforced programmatically.
- No versioning or extensibility mechanism: The classes are simple DTOs with no support for forward/backward compatibility (e.g., new fields would require breaking changes).