Hiển thị các bài đăng có nhãn database lock. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn database lock. Hiển thị tất cả bài đăng

Thứ Hai, 5 tháng 3, 2012

SAP's Lock Concept


In an Update request the data is changed for an entire SAP LUW (Logical Unit of Work), which are either carried out in full or not al all. An LUW can consist of multiple Transaction screens. So LUW can modify and update data consisting in multiple database objects (rows and tables), i.e. SAP’s LUW can result changes in many database objects. Sometimes only a few fields might be affected, so it might be required to lock only those affected fields, while rest of the fields can be used by other users. So therefore SAP has come out with its own Lock Concepts which can lock an object. An object in turn can lock a series of Database objects spread over many row and tables in the database level. Eg. When a User Master data is modified the data may affect more then one table in the Database Level, but Database can lock only at record level or a table level on one table. But SAP Locks will lock the entire object which could be spread over rows in all the affecting (here two) tables. The database lock exists only for the duration of the database LUW, in which the changes made in the SAP system are actually updated. And the SAP Lock is released once the LUW is commited or rolled back when the LUW is cancelled.

Why two different Enqueue Services for Java and ABAP.
Since SAP uses two separate schemas at the database, one each for ABAP and Java Stack. Data is saved is separately for ABAP and Java Stack. So enqueue process (locked objects) for Java would not interfere with the enqueue process (locked Objects) of ABAP stack.

Chủ Nhật, 29 tháng 1, 2012

SAP Workload Analysis - Chapter 3 Database Locks and R/3 Enqueue


In the work process overview – SM50, you can see that session B is not responding during a direct read for table NRIV. R/3 work process 405 has sent a SELECT SINGLE for table NRIV to the database and is now waiting for the database to return the requested data.
In monitor for database locks  – DB01, you can see why there is no response to the database request. Session B, which is run by WP 405, tries to create a lock on table NRIV, which is already locked by the R/3 work process 494. In the work process overview, you can see that work process 494 is processing session A.
To resolve the lock situation, session A must either release the lock or be cancelled.
The waiting session B causes SAP work process 405 to be blocked, which may cause wait situations for other users.
Situations like the one described are typically not caused by break points, but by lengthy processing of ABAP statements or SQL statements after they set a database lock. The lock on the database is released after the dialog step of session A is completed, and triggers a COMMIT or ROLLBACK.

Using R/3 enqueues and database locks.

Use enqueues to:
Explicitly exclude concurrent dialog access to data, thus preventing logical inconsistencies
A program using only read access does not need to use enqueues: Isolation levels can be used to achieve read consistency if necessary.
Database locks:
Are used in some special cases during the update phase
Should not be used in a dialog program
Exception: number ranges (SELECT single for update)
Locking and performance
Enqueues and database locks on central objects can serialize running transactions.
Avoid serialization:
In general, perform locks only when necessary
Keep locking times as short as possible:
For example, use array operations instead of single record insert/updates
For example, pre-aggregate data to enable one update instead of many
For number ranges: Fewer requirements cause less serialization
For available-to-promise quantities (ATP): additional logic can help to reduce locking times, especially over dialog steps.
For many enqueues, use bundling in a local enqueue container.

Use these two screens to detect high CPU usage on the database server.
Screen A, the operating system monitor – ST06, indicates a CPU utilization of 90% for user processes.
Screen B, shows the top CPU processes (ST06; Detailed analysis menu -> Top CPU processes). This screen reveals that 85.2% of the 2 CPU’s available are being used by the database process with PID 142.
High CPU usage of database processes for long periods typically indicates expensive SQL statements.

The database process monitor – ST04; oracle session can be used to analyze high CPU usage on the database server caused by expensive SQL statements. The Database process monitor enables you to display:
Database processes and the associated client processes (typically R/3 work processes).
The SQL statement currently being processed. To reveal the statement, dbl click the oracle process name. This is useful for statements that run for at least several seconds – short-running statements that are not expensive disappear too fast.

Screen A, showing the database process monitor, indicates that database process 296 is associated with the client process 494 on machine TWDFMX06.
After dbl clicking the line containing this oracle process, the database process monitor displays the expensive select on table ZLIPS: this statement is expensive because ZLIPS has many records and where clause is not supported by a suitable index. The EXPLAIN function for this SQL statement would indicate that a full table scan is being used.
Screen B, showing the work process overview – SM50 for application server TWDFMX06, identifies process 494 as an R/3 work process that is currently processing program ZZSELECT.