Consultor Eletrônico



Kbase P19984: The database .lk file
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   9/4/2006
Status: Verified

GOAL:

How Progress uses the database lock file ( .lk )

GOAL:

What is the .lk file used for?

FIX:

The database lock file (.lk) is the only protection we have against multiple processes starting the database. If multiple processes are allowed to start the database, then crash recovery will not work.

Associated Error messages:

** The database <file-name> is in use in single-user mode. (263)
** The database <file-name> is in use in multi-user mode. (276)
Broker disappeared, updating <file-name>.lk file. (4194)


WHAT'S IN THE LOCK FILE?

The .lk file contains three pieces of information:
1) The mode in which the database was started.
2) The process id (pid) of the process that started the database.
3) The hostname where the process that started it is running.

HOW DOES PROGRESS USE THIS INFORMATION?

When a process attempts to start a database it first tests for the existance of a .lk file. If there is no .lk file, the process creates it and starts up the database.

If a .lk file already exists, the process reads these three values to determine if it is a valid .lk file. This determination is performed as follows:

1) The process tests to see if it can run the gethostname() call. This should return the same information as a uname -n command. If this call fails, i.e. the gethostname() returned NULL, then no determination can be made about the .lk file, so we assume it is valid. Go to step 6.

2)Check if the hostname returned by the gethostname() call matches the hostname stored in the .lk file. If it does not match, then no determination can be made about the .lk file, so we assume it is valid. Go to step 6.

3)If the hostname matches (that is, we are on the same host that is in the .lk file), check if the pid stored in the .lk file is an active pid on the system.

4)If the pid is not active, then the .lk file is not valid, so we remove the existing .lk file, create a new one and startup the database.

5)If the pid is active, then the .lk file is valid and we cannot startup the database.

6)If the .lk file is valid, then we cannot startup the database and we return a message appropriate to the mode entry in the .lk file. If the .lk file is determined to be not valid, then we remove the existsing .lk file, create a new one, and startup the database.

Cautionary note:

Do NOT delete the .lk file while the database is in use, in either single or multi user mode. This is the only protection that exists to prevent multiple processes starting the database. If multiple processes are allowed to start the database, then crash recovery will most decidely not work!!

In those circumstances, where there has been some type of abnormal shutdown of the database or the system, and the .lk is not properly removed and IT HAS BEEN POSITIVELY ascertained that there are no progress processes accessing the database, then the .lk file can be deleted. DO NOT take this action lightly.

There is a known issue that has been in the Progress database for a long time where procopy|prodb does not put a lk file on the source database during execution. If another user/process connects to the source database while procopy is still running, the resulting target database will be corrupted. If you experience this issue regularly, please contact your Progress Technical Support.