当前位置:网站首页> 大表delete删数据导致数据库异常解决
大表delete删数据导致数据库异常解决
2022-07-07 13:11:00 【1024问】
一、问题描述
二、查看数据库情况
三、提出方案
四、执行过程
一、问题描述早上正在上班路上,群里客户说,有一张24G的大表,delete删了26小时还没有跑完,目前进程还在跑让帮忙处理下,停止当前进程,并保留对应条件的数据,多余数据删掉。
二、查看数据库情况1.未开归档
2.UNDO表空间爆满
三、提出方案1.经过沟通,该表为测试数据表,目前没有在使用;
于是打算rename该表,通过ctas的方式去将需要的数据捞出来,重建索引和相关约束。
2.存在一个问题:delete进程已经执行了26小时,如果kill进程,必然会导致undo回滚,回滚默认开启并行会导致数据库和系统负载很高,于是需要提前处理下,设置参数_fast_start_parallel_rollback_关掉UNDO并行。
--查看回滚参数设置,是否是默认并行SQL> show parameter fast_start_parallel_rollbackNAME TYPE VALUE------------------------------------ ----------- ------------------------------fast_start_parallel_rollback string LOW--LOW 代表 开启CPU*2并行--设置spfile取消并行SQL> alter system set fast_start_parallel_rollback=false;System altered.
四、执行过程1.备份保留 表创建语句。
2.记录当前无效对象。
SELECT d.OWNER ,d.OBJECT_NAME ,d.OBJECT_TYPE ,d.statusFROM dba_objects dWHERE d.status = 'INVALID' AND d.owner = '**';
3.查看delete进程pid,系统级kill掉。
--查询SID, SERIAL#select s.SQL_TEXT, se.SID, se.SERIAL# from v$session se, v$sql s where s.sql_id = se.SQL_ID and username = '**' and status = 'ACTIVE' and s.SQL_TEXT like '%delete * from *****%';--数据库级kill进程alter system kill session '2953,31083';
报错
ERROR at line 1:
ORA-00031: session marked for kill
--系统级 kill进程
select spid, osuser, s.program
from v$session s,v$process p
where s.paddr=p.addr and s.sid=2953;
kill -9 105257
4.观察undo回滚情况
--查看等待事件select inst_id,event,count(*) from gv$session a where a.status='ACTIVE' and not (a.type = 'BACKGROUND' and a.state='WAITING' and a.wait_class='Idle') group by inst_id,event order by a.inst_id,count(*) desc;---------------------------------------------------1wait for a undo record611resmgr:cpu quantum291enq: RO - fast object reuse221enq: CR - block range reuse ckpt201free buffer waits17--查看当前数据回滚情况alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';select usn, state, undoblockstotal "Total", undoblocksdone "Done", undoblockstotal - undoblocksdone "ToDo", decode(cputime, 0, 'unknown', sysdate + (((undoblockstotal - undoblocksdone) / (undoblocksdone / cputime)) / 86400)) "Estimated time to complete" from v$fast_start_transactions where state = 'RECOVERING';---------------------------------------------------83RECOVERING9026713455902625826-4月 -21
5.观察系统负载,IO负载,内存使用情况
6.等待回滚完成,持续时间较久。
7.回滚成功后,rename 原表。
rename table to table_20210410;
8.CTAS将需要的数据捞到新表(原来的表名)中。
create table USER.TABLEnologging parallel 8tablespace TBSas select /*+parallel(TABLE,'8')*/ * from USER.TABLE_20210410where *** like '******%';--取消并行alter table USER.TABLE noparallel;--开启loggingalter table USER.TABLE logging;
9.rename索引,并重建索引。
alter index USER.INDEX1 rename to INDEX1_20210410;--重建索引create index USER.INDEX1 on USER.TABLE (***) tablespace TBS parallel 8;--取消并行alter index USER.INDEX1 noparallel;
10.创建约束,授权。
11.比对无效对象,数据是否一致
12.drop掉rename的表。
drop table USER.TABLE_20210410 cascade;
以上就是大表delete删数据导致数据库异常解决的详细内容,更多关于delete删数据数据库异常的资料请关注软件开发网其它相关文章!
边栏推荐
- Briefly describe the working principle of kept
- Ctfshow, information collection: web9
- CTFshow,信息搜集:web3
- @ComponentScan
- 有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?
- Niuke real problem programming - Day12
- MySQL installation configuration 2021 in Windows Environment
- Zhiting doesn't use home assistant to connect Xiaomi smart home to homekit
- Several ways of JS jump link
- [机缘参悟-40]:方向、规则、选择、努力、公平、认知、能力、行动,读3GPP 6G白皮书的五层感悟
猜你喜欢
什么是数据泄露
Ctfshow, information collection: web12
Xiaomi's path of chip self-development
Niuke real problem programming - Day17
MySQL bit类型解析
How to enable radius two factor / two factor (2fa) identity authentication for Anheng fortress machine
Apache multiple component vulnerability disclosure (cve-2022-32533/cve-2022-33980/cve-2021-37839)
Why do we use UTF-8 encoding?
Unity之ASE实现卡通火焰
CTFshow,信息搜集:web4
随机推荐
Andriod --- JetPack :LiveData setValue 和 postValue 的区别
知否|两大风控最重要指标与客群好坏的关系分析
Change win10 Screensaver
leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
Ctfshow, information collection: web5
如何在opensea批量发布NFT(Rinkeby测试网)
[today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
微信小程序 01
Niuke real problem programming - Day9
Zhiting doesn't use home assistant to connect Xiaomi smart home to homekit
Unity's ASE achieves full screen sand blowing effect
时空可变形卷积用于压缩视频质量增强(STDF)
数据库如何进行动态自定义排序?
asp. Netnba information management system VS development SQLSERVER database web structure c programming computer web page source code project detailed design
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
Comparable and comparator of sorting
Niuke real problem programming - day20
Integer learning
Discussion on CPU and chiplet Technology
Ctfshow, information collection: web2