Lock Concept FAQ
The questions are sorted by topic areas.
• Architecture
• Programming
• Problem analysis
• High availability
• Performance
Architecture
Question
Where is the lock table stored?
Answer
In the main memory, shared memory, of the Enqueue Server. All work processes in the Enqueue server have access to it. External application servers execute their lock operations in the Enqueue process on the Enqueue server. Communication in this case takes place via the relevant dispatchers and the message server.
Question
Can locks exist directly after startup?
Answer
Yes, the saved locks, which were inherited by the update task, are reloaded to the lock table during startup (see first question).
Question
Why is an Enqueue work process required in a central system? Don't all work processes have the same access to the shared memory and thus to the lock table?
Answer
Although the Enqueue process is not used in a central system, it does not do any harm. Since almost all customers install an application server sooner or later, problems will inevitably arise if the Enqueue process is missing. For this reason, the Enqueue diagnosis function will output an error if an Enqueue process has not been configured.
Question
Are the locks in the lock table also set at the database level? If not, database functions could be used to process objects locked in the SAP system.
Answer
Locks are not set on the database. The lock table is stored in the main memory of the Enqueue server.
Question
Is a lock table built if an Enqueue work process is not started on the Enqueue server in the instance profile?
Answer
Yes, because the work processes on the Enqueue server use the lock table directly, and not via the Enqueue process. The latter is only responsible for lock requests from external application servers.
Programming
Question
What does the _SCOPE parameter mean? How does the lock owner concept work?
Answer
The application programmer uses this parameter to determine which of the two owners should actually own the lock. _SCOPE can have the values 1,2, or 3.
Person who holds a lock is called a lock owner. You can use this function to program different types of locks in your SAP programs. They are programmed in the lock administration.
Question
How can I find out who is currently holding the ungranted lock? In other words, how can check the program after an ENQUEUE to determine which use is currently holding the lock so that I can let him or her know?
Answer
When the ENQUEUE_... function module is returned, the name of the lock owner is listed in SY-MSGV1.
Question
Can I use special characters in my lock argument (especially the ‘at’ sign (@))?
Answer
The ‘at’ symbol is used as a wildcard in SAP locks (Enqueues). In other words, it can stand for any other character during collision checks. For example, the parameter value 12345@ locks the quantities 123450 to 123459, 12345a to 12345z, and 12345A to 12345Z, and all other values with any special character in the 6th character position.
In order to prevent the wildcard mechanism from being activated in SAP locks when it is not required, you need to ensure when Enqueue function modules are called that key value parameters do not contain any wildcard characters.
If key values that you want to use to lock individual entities do contain wildcard characters, you have to replace the wildcards with different characters before the Enqueue is called.
Problem Analysis
Question
What should I do first if a problem arises?
Answer
Use the diagnosis functions:
sm12 Extras Diagnosis and then
sm12 Extras Diagnosis in update
If a problem is reported, back up the trace files dev_w*, dev_disp, dev_eq* and check the Syslog.
Question
The following message is displayed in the diagnosis details in SM12:
Lock management operation mode
Internal lock management in same process
What does this message mean and what are the other options?
Answer
"Internal lock management in same work process" in the diagnosis function means that you are logged onto the Enqueue server and your work process can access the lock table straight away. You do not have to delegate Enqueue requests to an Enqueue process on a remote Enqueue server. If you are logged onto an application server that is not an Enqueue server, the diagnosis function will provide you with the name of the Enqueue server.
Each SAP System has exactly one application server that functions as an Enqueue server. This Enqueue server maintains the lock table, which is located in a shared memory segment. All of the work processes on the Enqueue server can access the lock table. All work processes on other application servers delegate their Enqueue requests to a special Enqueue work process on the Enqueue server.
This procedure is configured automatically. The parameter line "rdisp/enqname =<application>" in the default profile DEFAULT.PFL indicates which application server is currently acting as the Enqueue server. When an application server detects that its name matches the name of the Enqueue server, it creates the lock table and all of its work processes process Enqueue requests inline. If an application server detects that its name does not match the name of the Enqueue server, it sends all Enqueue requests to the Enqueue server.
Work processes of the type "Enqueue" guarantee that incoming requests are processed immediately. One Enqueue process is usually sufficient. In very large SAP Systems with many application servers, a second process can be beneficial. However, it is not expedient to define more than two Enqueue processes. If the transaction SM50 -> [CPU] shows that only the first Enqueue process is being used, the bottleneck is due to something else.
Question
The Syslog often contains messages such as "Enqueue: total wait time during locking: 2500 seconds". How should I analyze this problem? Or is the entry not critical? (There are no records of terminations or timeouts.)
Answer
The message is output for information purposes only but may indicate parallel processing errors with ABAP programs. The specified wait time is the time that has elapsed since startup due to the use of the WAIT parameter when the Enqueue function module was called.
The WAIT parameter enables a lock attempt to be repeated a number of times, for example, so that the update task does not have to be cancelled when a lock is set temporarily by other programs. The work process remains busy between the lock attempts.
High availability
Question
What happens to locks when the Enqueue server is restarted?
Answer
If they have not been saved to disk in the backup file, they will be lost. The locks that are inherited by the update task when COMMIT WORK is executed after CALL FUNCTION .. IN UPDATE TASK are saved to disk. The locks are saved to disk when the update request becomes valid, that is, with the COMMIT WORK. Each time the Enqueue server is restarted, the lock entries saved on the disk are reloaded to the lock table.
A lock is saved to disk at the point at which the backup flag is set.
If the Enqueue replication service is used as part of a high availability solution, locks will not be lost if the Enqueue server fails or is restarted. See next question.
Question
The Enqueue server is a single-point-of-failure in the SAP System. Can I guarantee high availability for the Enqueue Server?
Answer
To guarantee this you must use the standalone Enqueue Server with the Replication Server. This is described in the documentation Standalone Enqueue Server.
SAP note 524816 contains the prerequisites that must be fulfilled for using the standalone Enqueue Servers with the Replication Server.
Performance
Question
How fast are lock operations?
Answer
In work processes on the Enqueue server, a few 100 microseconds. In work processes of external application servers you have to include network communications and process changes. Depending on CPU and network load this amounts to a few milliseconds.
Question
With a single-process system as an Enqueue server, we have reached X SD Benchmark users. Can this number be increased by using a multiprocessor system (message server on the same machine as the Enqueue server)? Can we assume that scaling is linear (number of CPUs * X SD users)? How many processes are advisable if message servers, dispatchers, one dialog, and two Enqueue processes are to run on the system?
Answer
A significant increase in the Enqueue server throughput can be expected by using several processors. The CPU load on the Enqueue server is distributed relatively evenly between message servers, dispatchers, and Enqueue work processes, which means that up to 3 processors can be occupied simultaneously. The dispatchers and the message server represent the bottleneck with the Enqueue.
Linear scaling can be expected for up to three processors, even if lock requests are so frequent that message server, dispatchers, and work processes are occupied simultaneously. Due to asynchronous system processes (for example, syncer), using more processors can further enhance throughput.