当前位置:网站首页>Simulate Oracle lock waiting and manual unlocking
Simulate Oracle lock waiting and manual unlocking
2022-06-11 20:01:00 【huryer】
simulation Oracle Lock waiting and manual unlocking
1、 purpose
This paper describes in Oracle When the database is locked and waiting , If you view lock information , And how to unlock .
2、 Simulation process
2.1、 Create test table
-- The first 1 Procedures ---------------------------------------------
-- Create test table
CREATE TABLE t1(
id INT,
name VARCHAR(10)
)
;
-- Write test data , And submit
DELETE FROM t1;
insert into t1(id,name) values(1,'a');
insert into t1(id,name) values(2,'b');
commit;
2.2、 Simulate lock waiting
-- The first 1 individual sqlplus Program ---------------------------------------------
-- View the current session, And update the data :
select userenv('sid') from dual;
update t1 set name = 'a1' where id = 1;
-- The first 2 individual sqlplus Program ---------------------------------------------
-- Open one more sqlplus Program , perform sql, It's blocked
select userenv('sid') from dual;
update t1 set name = 'a2' where id = 1;
2.3、 Analysis lock wait
-- The first 3 Procedures ---------------------------------------------
-- View locking process sql sentence
select distinct s.sid
, s.serial#
, s.blocking_session /* Which is currently being sid Blocking */
, s.client_info /* Client information (ip)*/
, s.machine /* Host name */
, s.osuser /* Operating system users */
, s.program /* Program name */
, s.seconds_in_wait /* The waiting time ( second )*/
, s.event /* event */
, s.status /* state */
, s.wait_class /* Waiting class */
, lo.oracle_username /*oracle user */
, lo.locked_mode /* Lock mode */
, ao.object_name /* Locked objects */
, s1.sql_text as sql_current /* Currently executed sql*/
, s2.sql_text as sql_previous /* Previous execution sql*/
from v$locked_object lo
, dba_objects ao
, v$session s
left join v$sql s1 on s1.sql_id = s.sql_id
left join v$sql s2 on s2.sql_id = s.prev_sql_id
where ao.object_id = lo.object_id
and lo.session_id = s.sid
;
The lock waiting condition is shown in the following figure :
2.4、 Unlock wait
You can use the following 2 There are three ways to lock
1、 Commit or rollback the 1 Procedures
commit;
rollback;
2、 End the... Manually 1 individual session
alter system kill session 'sid,serial#';
Observe No 2 Programs can continue to execute .
2.5、 Summary
This article is only used to simulate the occurrence and unlocking process of lock waiting . In actual projects , Can pass sql Query lock waiting list , Export problem data , And unlock it in time , Analyze the problem afterwards .
边栏推荐
- 09-MySQL锁
- 使用flask框架写挡板
- Leetcode2027. Minimum number of operations to convert a string (yes, once)
- MySQL——基本的Select语句
- Introduction to typescript
- unity里面使用opencv,qt建立plugin(一)
- 556. next larger element iii- (31. next permutation) - two iterations
- The principle that the picture of QQ Post Bar changes when it is opened
- QQ贴吧那种图片一点开,就变了的原理
- [advanced MySQL] differences among 10 data types and how to optimize the table structure (3)
猜你喜欢

Usage of duck beak wire stripper

STC 纯硬件自动下载电路 V2

dried food! Information diffusion prediction based on sequence hypergraph neural network

A Mechanics-Informed Artificial Neural Network Approach in Data-Driven Constitutive Modeling 学习

Interface isolation principle

计算926的9260次方里的字符串里有多少个926

This article introduces you to the infrastructure of sofaregistry

27. this指向问题

2022年最新宁夏建筑八大员(标准员)考试试题及答案

In 2021, the global adult diaper revenue was about $11560million, which is expected to reach $15440million in 2028. From 2022 to 2028, the CAGR was 4.2%
随机推荐
Activate function formulas, derivatives, image notes
My favorite product management template - Lenny
Offline assignment template and requirements of the course design of real estate development and operation in the 21st autumn of Dagong [standard answer]
556. next larger element iii- (31. next permutation) - two iterations
里氏替换原则
Zzulioj 2903: the power of warriors
Interface isolation principle
The first bullet of comparative learning
JMeter installation
VS2010 cannot open when linking sql2008 database
何恺明团队的“视频版本MAE”,高效视频预训练!Mask Ratio高达90%时效果也很好!...
[Err] 1045 - Access denied for user ‘root‘@‘%‘ (using password: YES)
Hdu3527 (Hangdian) spy problem
Summary 111111111111111111111
2022Redis7.0x版本持久化详细讲解
干货!基于序列超图神经网络的信息扩散预测
Flutter doctor 显示xcode没有安装的解决办法
【求助】請問如何讓微信公眾號文章在外部瀏覽器中打開後還能顯示下方的精選留言?
Questions and requirements of the "high rise building structure" assignment of Dayong in the 21st autumn [standard answer]
[Sichuan University] information sharing of the first and second examinations