Trace file locks
In order to detect locking problems in multi-user applications, file locks may be traced. In order to trace file locks, the option
- TraceLocks=YES
has to be set to true (YES). File locks are written to the directory referenced in the TRACE option;
%TRACE%/userName_processID.lck
Since lock trace files may become very large, trace information is stored as binary data with the following structure:
struct _LockTrace {
DateTime timestamp; // lock/unlock time
int64position;// file position
int32length;// lock length
char operation; // +: lock, -: unlock
};
In order to keep lock files small, the lock file directory should refer to users home directory.
In order to analyze lock data, a lock trace database may be created by loading single files of all lock trace files (*.lck) in a directory (see example below).In order to run the analysis, naming conventions as described above, are required. The procedure creates an import database with two extents:
ObjectLocks: contains locks for each process
int32 pid; // process id
STRING(20)user;// file name without extension
SET<ObjectLock> locks; // locks for this process
ObjectLock contains all locks/unlocks
int32 pid; // process id
STRING(20)user;// file name without extension
DateTimetimestamp; // last lock/unlock time for position
int64 position;// file position
int32 length;// lock length
int32 cnt; // number of currently active locks
When importing lock trace files, a lock summary record is created for pid, position and length. The cnt field contains the number of currently active locks for the file lock in the current process.
In order to select locks for a certain time interval and a specific file position, the ObjectLock::List function may be called, which creates a result file in the TRACE directory (directory defined in the TRACE option).
// data source definition for LockDB
[LockDB]
DICTIONARY=ode.sys
RESOURCES=ode.dev
DATABASE=LockDB.dat
NET=YES
ACCESS_MODE=Write
// OShell script for importing a directory
// delete LockDB.dat before running
// ObjectLocks implemented in ode.dev/adk
cd LockDB
cc ObjectLocks
osi do
ImportDirectory('~/locks');
end
cc /ObjectLock
osi do
List('2018-01-05|10:00:00.00','2018-01-05|12:30:00.00','281474976849513');
List('2018-01-05|10:00:00.00','2018-01-05|12:30:00.00','163636493');
end