commit_write,commit_logging,commit_wait引數和oracle redo行為
Managing Commit Redo Action
When a transaction updates the database, it generates a redo entry corresponding to this update. Oracle Database buffers this redo in memory until the completion of the transaction. When the transaction commits, the log writer process (LGWR) writes redo for the commit, along with the accumulated redo of all changes in the transaction, to disk. By default, Oracle Database writes the redo to disk before the call returns to the client. This action introduces a latency in the commit because the application must wait for the redo to be persisted on disk.
Suppose that you are writing an application that requires very high transaction throughput. If you are willing to trade commit durability for lower commit latency, then you can change the default COMMIT options so that the application need not wait for the database to write data to the online redo logs.
Oracle Database enables you to change the handling of commit redo depending on the needs of your application. You can change the commit action in the following locations:
- COMMIT_WRITE initialization parameter at the system or session level
- COMMIT statement
The options in the COMMIT statement override the current settings in the initialization parameter. Table 2-1 describes redo persistence options that you can set in either location.
Caution:
With the NOWAIT option of COMMIT or COMMIT_WRITE, a failure that occurs after the commit message is received, but before the redo log record(s) are written, can falsely indicate to a transaction that its changes are persistent.
Table 2-1 Options of COMMIT Statement and COMMIT_WRITE Initialization Parameter
Option |
Effect |
WAIT (default) |
Ensures that the commit returns only after the corresponding redo information is persistent in the online redo log. When the client receives a successful return from this COMMIT statement, the transaction has been committed to durable media. A failure that occurs after a successful write to the log might prevent the success message from returning to the client, in which case the client cannot tell whether or not the transaction committed. |
NOWAIT |
The commit returns to the client whether or not the write to the redo log has completed. This behavior can increase transaction throughput. |
BATCH |
The redo information is buffered to the redo log, along with other concurrently executing transactions. When sufficient redo information is collected, a disk write to the redo log is initiated. This behavior is called group commit, as redo information for multiple transactions is written to the log in a single I/O operation. |
IMMEDIATE (default) |
LGWR writes the transaction's redo information to the log. Because this operation option forces a disk I/O, it can reduce transaction throughput. |
The following example shows how to set the commit action to BATCH and NOWAIT in the initialization parameter file:
COMMIT_WRITE = BATCH, NOWAIT
You can change the commit action at the system level by executing ALTER SYSTEM as in the following example:
ALTER SYSTEM SET COMMIT_WRITE = BATCH, NOWAIT
After the initialization parameter is set, a COMMIT statement with no options conforms to the options specified in the parameter. Alternatively, you can override the current initialization parameter setting by specifying options directly on the COMMIT statement as in the following example:
COMMIT WRITE BATCH NOWAIT
In either case, your application specifies that log writer does not have to write the redo for the commit immediately to the online redo logs and need not wait for confirmation that the redo was written to disk.
Note:
You cannot change the default IMMEDIATE and WAIT action for distributed transactions.
If your application uses OCI, then you can modify redo action by setting the following flags in the OCITransCommit function within your application:
- OCI_TRANS_WRITEBATCH
- OCI_TRANS_WRITENOWAIT
- OCI_TRANS_WRITEIMMED
- OCI_TRANS_WRITEWAIT
Caution:
There is a potential for silent transaction loss when you use OCI_TRANS_WRITENOWAIT. Transaction loss occurs silently with shutdown termination, startup force, and any instance or node failure. On a RAC system asynchronously committed changes might not be immediately available to read on other instances.
The specification of the NOWAIT and BATCH options has a small window of vulnerability in which Oracle Database can roll back a transaction that your application view as committed. Your application must be able to tolerate the following scenarios:
- The database host fails, which causes the database to lose redo that was buffered but not yet written to the online redo logs.
- A file I/O problem prevents log writer from writing buffered redo to disk. If the redo logs are not multiplexed, then the commit is lost.
COMMIT_WRITE
Property |
Description |
Parameter type |
String |
Syntax |
COMMIT_WRITE = '{IMMEDIATE | BATCH},{WAIT |NOWAIT}' |
Default value |
If this parameter is not explicitly specified, then database commit behavior defaults to writing commit records to disk before control is returned to the client. If only IMMEDIATE or BATCH is specified, but not WAIT or NOWAIT, then WAIT mode is assumed. If only WAIT or NOWAIT is specified, but not IMMEDIATE or BATCH, then IMMEDIATE mode is assumed |
Modifiable |
Yes (at both session-level and system-level). Values supplied for COMMIT_WRITE in an ALTER SYSTEM or ALTER SESSION statement must be separated by a comma. |
Range of values |
Single-quoted, comma-separated list of either IMMEDIATE or BATCH, and either WAIT or NOWAIT. |
Basic |
No |
Real Application Clusters |
Each instance may have its own setting |
COMMIT_WRITE is an advanced parameter used to control how redo for transaction commits is written to the redo logs. The IMMEDIATE and BATCH options control how redo is batched by Log Writer. The WAIT and NOWAIT options control when the redo for a commit is flushed to the redo logs.
COMMIT_WAIT
Property |
Description |
Parameter type |
String |
Syntax |
|
Default value |
There is no default value. |
Modifiable |
Yes (at both session-level and system-level) |
Basic |
No |
Oracle RAC |
Each instance may have its own setting |
COMMIT_WAIT
is an advanced parameter used to control when the redo for a commit
is flushed to the redo logs.
Be aware that the NOWAIT
option can cause
a failure that occurs after the database receives the commit message, but
before the redo log records are written. This can falsely indicate to a
transaction that its changes are persistent. Also, it can violate the
durability of ACID (Atomicity, Consistency, Isolation, Durability) transactions
if the database shuts down unexpectedly.
If the parameter is set to FORCE_WAIT
, the default
behavior (immediate flushing of the redo log buffer with wait) is used. If this
is a system setting, the session level and transaction level (COMMIT_WRITE
)
options will be ignored. If this is a session level setting, the transaction
level options will be ignored. If COMMIT_WAIT
is altered
after it has been set to FORCE_WAIT
, then the FORCE_WAIT
option is no longer valid.
COMMIT_LOGGING
Property |
Description |
Parameter type |
String |
Syntax |
|
Default value |
There is no default value. |
Modifiable |
Yes (at both session-level and system-level) |
Basic |
No |
Oracle RAC |
Each instance may have its own setting |
COMMIT_LOGGING
is an advanced parameter used to control how redo is batched by Log
Writer.
If COMMIT_LOGGING
is altered after setting COMMIT_WAIT
to FORCE_WAIT
,
then the FORCE_WAIT
option is no longer valid.
commit_write引數只在Oracle 10gR2中有效,在oracle 11g中被commit_logging和commit_wait取代。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26651/viewspace-1040530/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- commit_write引數MIT
- oracle的redo和undoOracle
- Oracle Redo 並行機制Oracle Redo並行
- Oracle中INITRANS和MAXTRANS引數Oracle
- Oracle和SUN Solaris核心引數Oracle
- oracle redo和undo系列一Oracle Redo
- Linux 核心引數 和 Oracle相關引數調整LinuxOracle
- Oracle引數-隱藏引數Oracle
- Oracle 引數檔案(spfile和pfile)Oracle
- Oracle和SUN Solaris核心引數(轉)Oracle
- commit_writeMIT
- oracle 引數Oracle
- kettle 引數——變數引數和常量引數變數
- 【REDO】Oracle redo undo 學習Oracle Redo
- 【引數】REMOTE_LOGIN_PASSWORDFILE引數三種取值及其行為特性分析REM
- 關於C++引用做為函式引數和指標作為函式引數C++函式指標
- MySQL中Redo Log相關的重要引數總結MySql
- 匿名自執行函式的引數為什麼是window和undefined函式Undefined
- Oracle的redo 和undo的區別Oracle
- Java進行post和get傳引數Java
- Oracle引數檔案解析——引數解析Oracle
- 在AIX下為Oracle調整網路引數AIOracle
- oracle procedure輸入引數為date日期小記Oracle
- Oracle11g調整redo日誌大小、組數和每組成員數Oracle
- Oracle 核心引數Oracle
- Oracle UNDO引數Oracle
- Oracle引數大全Oracle
- oracle引數配置Oracle
- oracle 效能引數Oracle
- ORACLE核心引數Oracle
- oracle引數整理Oracle
- 【REDO】Oracle redo內部結構Oracle Redo
- 【REDO】Oracle redo advice-sqlOracle RedoSQL
- 通過行為引數化傳遞程式碼
- oracle隱藏引數的檢視和使用Oracle
- Oracle Redo and UndoOracle Redo
- 你知道Chrome Network ,Size 和 Time 為什麼有兩行引數嗎?Chrome
- Oracle引數檔案 各引數解釋Oracle