This article describes how to easily master the actual operation steps of database memory protection in DB2 9.5. in DB2 9.5, the database engine changes from the process mode to the thread mode, which means that the entire database engine is in an address space (any code segment can access any global variables ).
This naturally has both advantages and disadvantages. One advantage is that the thread is "lighter" than the process, which indicates that DB2 has better performance. Some tests show that the performance of DB2 9.5 is 9.1 to 2% higher than that of DB2 5% in the same state under load.
The disadvantage is that any db2 error in any db2 code path unrelated to the buffer pool may damage the data page. In addition, unfenced udfs that share the same address space with db2 in unprotected mode may also damage the Memory Page.
Then, these incorrect data pages will be written to the disk without notice, and you may never know that the data has been inconsistent. The thread mode also generates security issues related to user-defined functions in non-protected mode, this is because the thread mode allows malicious user code to read and write data pages without authorization.
If you run user-defined functions in fensed mode, none of these problems will occur. The user code will be executed through a sub-process and communicate with DB2 through IPC, the only problem is that this is much slower than running in unprotected mode.
When IBM's Power6 CPU went public, a new technology for memory protection was also introduced, namely, the user-level storage key technology. This is not to say that the kernel-level storage key has existed for a period of time, while the user-level storage key is a new thing. The storage key enables the application to lock the Memory Page to prevent any form of read/write combinations.
The storage key on the CPU must be supported because the memory access speed is very fast (in nanoseconds) and cannot be achieved at the software level. The storage key enables the DB2 engine executed in the user space to prevent the code segment from performing unauthorized read/write operations on the buffer pool data page. Of course, if you are running the Power6 processor on AIX, this is only one of the optional protection measures. Starting this function requires 5% to 6% performance overhead. Use the following statement to start the function:
The following is a reference clip:
- db2set DB2_MEMORY_PROTECT=yes
- RESTART YOUR INSTANCE
Run the AIX 5.3 ML6 (or later) or AIX 6.1 operating system.
If you are still developing c or C ++ code on AIX and are not applicable to Java, you can use the ukey_protect (address, size, UKEY_PRIVATE) function to protect the data memory structure. The above content is an introduction to teach you how to easily master the database memory protection of DB2 9.5. I hope you will gain some benefits.
The above content is an introduction to teach you how to easily master the database memory protection of DB2 9.5. I hope you will gain some benefits.