简体   繁体   中英

Oracle Transactions in a PLSQL procedure

I have a Oracle job that is executing every second and updating the T_USER table, I am wondering if during the execution of the job the table is blocked and other processes like a Web. app. that is using this DB will be blocked.

Oracle uses row-level locking. Therefore you have to look at different situations:

1.) The web app and your job affect different rows: You are fine.

2.) The web app and your job affect the same row and the locking time (the time between the UPDATE and the COMMIT) is short you should be fine. Oracle will serialize the execution.

3.) Either your job or the web app will hold locks for a long time. This will be noticeable: Oracle will wait for the transaction to complete. The job or app might hang during this time but should work fine. If the lock time is hours than you might run into problems with timeouts or impatient users.

4.) Your job and your app update multiple rows and hold locks for these rows for a longer time and job and app affect the same rows. This is dangerous. You might run into deadlocks because your job is holding a lock on Row A and wants to update Row B and your app is holding a lock on Row B and wants to update Row A. In such a situation Oracle will raise an exception for one of the two sessions - either the job or the app. This is pretty annoying because it can be very hard to reproduce and to analyze.

You have to decide yourself which case you actually fall under.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM