使用 ErrorStack 在出现报错 ORA-14402 时产生的日志量

news/2024/9/3 21:14:04 标签: oracle, 数据库, dba, oracle运维

=======================================================

0、测试结论:

测试结果:设置 ErrorStack 级别为 1 时产生 Trace 的日志量最小,大小为 308K,同时在 alert 日志中也存在记录。

1、准备测试数据:

sqlplus / as sysdba

show pdbs

alter session set container=pdb;

create table my_part_table
(
  id int not null,
  addr varchar2(20))
  partition by range (id)
 (
  partition p1 values less than (1000),
  partition P2 values less than (2000),
  partition P3 values less than (maxvalue)
 );

insert into my_part_table values(1,'addr1');
insert into my_part_table values(2,'addr2');
insert into my_part_table values(3,'addr3');

insert into my_part_table values(1001,'addr1001');
insert into my_part_table values(1002,'addr1002');
insert into my_part_table values(1003,'addr1003');

insert into my_part_table values(2001,'addr2001');
insert into my_part_table values(2002,'addr2002');
insert into my_part_table values(2003,'addr2003');

commit;

select rowid,a.* from my_part_table partition(p1) a;

select rowid,a.* from my_part_table partition(p2) a;

select rowid,a.* from my_part_table partition(p3) a;

2、设置 ErrorStack 级别为 3 时捕获跟踪详细日志:

alter session set events='14402 trace name errorstack forever,level 3';

3、执行对 Oracle 分区表分区字段更新操作:

update my_part_table set id=3001 where id=1;

4、检查产生的日志量:

set linesize 200 pagesize 999
col tracefile format a100
select spid,tracefile from v$process a where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum=1));

ls -ltrh <通过上述查询得出的 trace 文件名>

测试结果:设置 ErrorStack 级别为 3 时产生 Trace 的日志量为 5.4M,同时在 alert 日志中也存在记录。

5、设置 ErrorStack 级别为 1 时产生的日志量:

conn / as sysdba

alter session set container=pdb;

alter session set events='14402 trace name errorstack forever,level 1';

update my_part_table set id=3002 where id=2;

set linesize 200 pagesize 999
col tracefile format a100
select spid,tracefile from v$process a where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum=1));

ls -ltrh <通过上述查询得出的 trace 文件名>

测试结果:设置 ErrorStack 级别为 1 时产生 Trace 的日志量为 308K,同时在 alert 日志中也存在记录。

6、设置 ErrorStack 级别为 0 时产生的日志量:

conn / as sysdba

alter session set container=pdb;

alter session set events='14402 trace name errorstack forever,level 0';

update my_part_table set id=3003 where id=3;

set linesize 200 pagesize 999
col tracefile format a100
select spid,tracefile from v$process a where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum=1));

ls -ltrh <通过上述查询得出的 trace 文件名>

测试结果:设置 ErrorStack 级别为 0 时不产生 Trace 日志,同时在 alert 日志中不存在记录。

=======================================================

附录 1 - 测试日志:

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE   RESTRICTED
    ----------   ------------------------------       ----------             ----------
             2    PDB$SEED                        READ ONLY     NO
             3    PDB                                    READ WRITE   NO
SQL> alter session set container=pdb;

Session altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDB                            READ WRITE NO
SQL> create table my_part_table
  2  (
  3    id int not null,
  4    addr varchar2(20))
  5    partition by range (id)
  6   (
  7    partition p1 values less than (1000),
  8    partition P2 values less than (2000),
  9    partition P3 values less than (maxvalue)
 10   );

Table created.

SQL> insert into my_part_table values(1,'addr1');

1 row created.

SQL> insert into my_part_table values(2,'addr2');

1 row created.

SQL> insert into my_part_table values(3,'addr3');

1 row created.

SQL> insert into my_part_table values(1001,'addr1001');

1 row created.

SQL> insert into my_part_table values(1002,'addr1002');

1 row created.

SQL> insert into my_part_table values(1003,'addr1003');

1 row created.

SQL> insert into my_part_table values(2001,'addr2001');

1 row created.

SQL> insert into my_part_table values(2002,'addr2002');

1 row created.

SQL> insert into my_part_table values(2003,'addr2003');

1 row created.

SQL> commit;

Commit complete.

SQL> select rowid,a.* from my_part_table partition(p1) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF28AABAAAHmxAAA          1 addr1
AAAF28AABAAAHmxAAB          2 addr2
AAAF28AABAAAHmxAAC          3 addr3

SQL> select rowid,a.* from my_part_table partition(p2) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF29AABAAAHm5AAA       1001 addr1001
AAAF29AABAAAHm5AAB       1002 addr1002
AAAF29AABAAAHm5AAC       1003 addr1003

SQL> select rowid,a.* from my_part_table partition(p3) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF2+AABAAAHnBAAA       2001 addr2001
AAAF2+AABAAAHnBAAB       2002 addr2002
AAAF2+AABAAAHnBAAC       2003 addr2003

SQL> alter session set events='14402 trace name errorstack forever,level 3';

Session altered.

SQL> update my_part_table set id=3001 where id=1;
update my_part_table set id=3001 where id=1
                                      *
ERROR at line 1:
ORA-14402: updating partition key column would cause a partition change


SQL> set linesize 200 pagesize 999
SQL> col tracefile format a100
SQL> select spid,tracefile from v$process a where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum=1));

SPID                     TRACEFILE
------------------------ ----------------------------------------------------------------------------------------------------
53919                    /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_53919.trc

SQL> host ls -ltrh /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_53919.trc
-rw-r----- 1 oracle asmadmin 5.4M Sep 21 10:40 /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_53919.trc

SQL> host tail -15 /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/alert_yqbdb1.log
Pluggable database PDB opened read write
Completed: alter pluggable database pdb open
2023-09-21T10:40:05.964639+08:00
PDB(3):Errors in file /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_53919.trc:
ORA-14402: updating partition key column would cause a partition change
2023-09-21T10:40:08.246821+08:00
PDB(3):*****************************************************************
PDB(3):An internal routine has requested a dump of selected redo.
PDB(3):This usually happens following a specific internal error, when
PDB(3):analysis of the redo logs will help Oracle Support with the
PDB(3):diagnosis.
PDB(3):It is recommended that you retain all the redo logs generated (by
PDB(3):all the instances) during the past 12 hours, in case additional
PDB(3):redo dumps are required to help with the diagnosis.
PDB(3):*****************************************************************

SQL> conn / as sysdba
Connected.
SQL> alter session set container=pdb;

Session altered.

SQL> alter session set events='14402 trace name errorstack forever,level 1';

Session altered.

SQL> update my_part_table set id=3002 where id=2;
update my_part_table set id=3002 where id=2
       *
ERROR at line 1:
ORA-14402: updating partition key column would cause a partition change


SQL> set linesize 200 pagesize 999
SQL> col tracefile format a100
SQL> select spid,tracefile from v$process a where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum=1));

SPID                     TRACEFILE
------------------------ ----------------------------------------------------------------------------------------------------
69852                    /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_69852.trc

SQL> host ls -ltrh /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_69852.trc
-rw-r----- 1 oracle asmadmin 308K Sep 21 11:05 /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_69852.trc

SQL> host tail -15 /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/alert_yqbdb1.log
PDB(3):Errors in file /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_53919.trc:
ORA-14402: updating partition key column would cause a partition change
2023-09-21T10:40:08.246821+08:00
PDB(3):*****************************************************************
PDB(3):An internal routine has requested a dump of selected redo.
PDB(3):This usually happens following a specific internal error, when
PDB(3):analysis of the redo logs will help Oracle Support with the
PDB(3):diagnosis.
PDB(3):It is recommended that you retain all the redo logs generated (by
PDB(3):all the instances) during the past 12 hours, in case additional
PDB(3):redo dumps are required to help with the diagnosis.
PDB(3):*****************************************************************
2023-09-21T11:05:30.198564+08:00
PDB(3):Errors in file /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_69852.trc:
ORA-14402: updating partition key column would cause a partition change

SQL> conn / as sysdba
Connected.
SQL> alter session set container=pdb;

Session altered.

SQL> alter session set events='14402 trace name errorstack forever,level 0';

Session altered.

SQL> update my_part_table set id=3003 where id=3;
update my_part_table set id=3003 where id=3
       *
ERROR at line 1:
ORA-14402: updating partition key column would cause a partition change


SQL> set linesize 200 pagesize 999
SQL> col tracefile format a100
SQL> select spid,tracefile from v$process a where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum=1));

SPID                     TRACEFILE
------------------------ ----------------------------------------------------------------------------------------------------
81453                    /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_81453.trc

SQL> host ls -ltrh /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_81453.trc
ls: cannot access /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_81453.trc: No such file or directory

SQL> host tail -15 /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/alert_yqbdb1.log
PDB(3):Errors in file /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_53919.trc:
ORA-14402: updating partition key column would cause a partition change
2023-09-21T10:40:08.246821+08:00
PDB(3):*****************************************************************
PDB(3):An internal routine has requested a dump of selected redo.
PDB(3):This usually happens following a specific internal error, when
PDB(3):analysis of the redo logs will help Oracle Support with the
PDB(3):diagnosis.
PDB(3):It is recommended that you retain all the redo logs generated (by
PDB(3):all the instances) during the past 12 hours, in case additional
PDB(3):redo dumps are required to help with the diagnosis.
PDB(3):*****************************************************************
2023-09-21T11:05:30.198564+08:00
PDB(3):Errors in file /oracle/app/oracle/diag/rdbms/yqbdb/yqbdb1/trace/yqbdb1_ora_69852.trc:
ORA-14402: updating partition key column would cause a partition change

SQL> 

附录 2 - 解决 Oracle 分区表不能更新分区字段的方法:

默认情况下,Oracle 分区表对于分区字段是不允许进行 update 操作的,如果更新就会报 ORA-14402 错误,解决方法是临时开启表的 row movement 属性:

alter table my_part_table enable row movement;

update my_part_table set id=3003 where id=3;

commit;

select rowid,a.* from my_part_table partition(p1) a;

select rowid,a.* from my_part_table partition(p2) a;

select rowid,a.* from my_part_table partition(p3) a;

alter table my_part_table disable row movement;

update my_part_table set id=3002 where id=2;

限制:对于普通表( heap-organized )行迁移后 rowid 会发生变化,对于索引表( index-organized )rowid 虽然依然有效但是其实际对应的物理构成是错误的。

测试日志:

SQL> conn / as sysdba
Connected.
SQL> alter session set container=pdb;

Session altered.

SQL> select rowid,a.* from my_part_table partition(p1) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF3HAABAAAHnJAAA          1 addr1
AAAF3HAABAAAHnJAAB          2 addr2
AAAF3HAABAAAHnJAAC          3 addr3

SQL> select rowid,a.* from my_part_table partition(p2) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF3IAABAAAHnRAAA       1001 addr1001
AAAF3IAABAAAHnRAAB       1002 addr1002
AAAF3IAABAAAHnRAAC       1003 addr1003

SQL> select rowid,a.* from my_part_table partition(p3) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF3JAABAAAHnZAAA       2001 addr2001
AAAF3JAABAAAHnZAAB       2002 addr2002
AAAF3JAABAAAHnZAAC       2003 addr2003

SQL> update my_part_table set id=3003 where id=3;
update my_part_table set id=3003 where id=3
       *
ERROR at line 1:
ORA-14402: updating partition key column would cause a partition change


SQL> alter table my_part_table enable row movement;

Table altered.

SQL> update my_part_table set id=3003 where id=3;

1 row updated.

SQL> commit;

Commit complete.

SQL> select rowid,a.* from my_part_table partition(p1) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF3HAABAAAHnJAAA          1 addr1
AAAF3HAABAAAHnJAAB          2 addr2

SQL> select rowid,a.* from my_part_table partition(p2) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF3IAABAAAHnRAAA       1001 addr1001
AAAF3IAABAAAHnRAAB       1002 addr1002
AAAF3IAABAAAHnRAAC       1003 addr1003

SQL> select rowid,a.* from my_part_table partition(p3) a;

ROWID                      ID ADDR
------------------ ---------- --------------------
AAAF3JAABAAAHnZAAA       2001 addr2001
AAAF3JAABAAAHnZAAB       2002 addr2002
AAAF3JAABAAAHnZAAC       2003 addr2003
AAAF3JAABAAAHnZAAD       3003 addr3

SQL> alter table my_part_table disable row movement;

Table altered.

SQL> update my_part_table set id=3002 where id=2;
update my_part_table set id=3002 where id=2
       *
ERROR at line 1:
ORA-14402: updating partition key column would cause a partition change


http://www.niftyadmin.cn/n/5082566.html

相关文章

【使用 TensorFlow 2】02/3 使用 Lambda 层创建自定义激活函数

一、说明 TensorFlow 2发布已经接近2年时间&#xff0c;不仅继承了Keras快速上手和易于使用的特性&#xff0c;同时还扩展了原有Keras所不支持的分布式训练的特性。3大设计原则&#xff1a;简化概念&#xff0c;海纳百川&#xff0c;构建生态.这是本系列的第三部分&#xff0c;…

优盘无法格式化?分享简单解决方法!

“我的优盘插入了一个带病毒的电脑中&#xff0c;现在优盘也中毒了&#xff0c;想把它格式化。但是操作的时候却显示优盘无法格式化&#xff0c;这种情况应该怎么办呢&#xff1f;” 优盘&#xff0c;又称USB闪存驱动器。由于其体积小且方便携带&#xff0c;受到广大电脑用户的…

OrcaTerm AI

&#x1f648;作者简介&#xff1a;练习时长两年半的Java up主 &#x1f649;个人主页&#xff1a;程序员老茶 &#x1f64a; ps:点赞&#x1f44d;是免费的&#xff0c;却可以让写博客的作者开心好久好久&#x1f60e; &#x1f4da;系列专栏&#xff1a;Java全栈&#xff0c;…

Unity引擎:收费模式和服务升级,为游戏开发带来更多可能性

Unity 引擎的收费模式和配套服务升级已经引起了广泛的关注和讨论。自 2024 年 1 月 1 日起&#xff0c;Unity 将根据游戏的安装量对开发者进行收费。这将会影响到很多游戏开发者和玩家。本文将探讨 Unity 引擎的收费模式和配套服务更新&#xff0c;以及对游戏开发者和玩家的影响…

mysql kill 杀死异常线程 死锁 执行时间长 sleep running lock 等

省流&#xff1a; 查询正在进行的事务 SELECT * FROM information_schema.innodb_trx;#根据条件查processlist select * from information_schema.processlist where idxx;杀死进程 kill id; 正文&#xff1a; 经常会遇到mysql死锁等突发情况。 这次遇到一个进程执行时间过长…

c 语言基础题目:L1-034 点赞

微博上有个“点赞”功能&#xff0c;你可以为你喜欢的博文点个赞表示支持。每篇博文都有一些刻画其特性的标签&#xff0c;而你点赞的博文的类型&#xff0c;也间接刻画了你的特性。本题就要求你写个程序&#xff0c;通过统计一个人点赞的纪录&#xff0c;分析这个人的特性。 …

【Java自定义工具类】百分比计算工具类以及计算相关的问题(138)

详解&#xff1a; 1.列举了4种百分比转化方式&#xff1b; 2.解决百分比计算加和不为100%的问题&#xff1b; 3.百分比计算保留小数点后一位或者两位或者N位&#xff1b; 4.double类型数字相加减的时候结果与预期不符合&#xff1b; 5.不同入参方式计算&#xff08;数组和单个值…

Spring Cloud 2023 新特性 同步网关

网关不支持传统 Servlet 容器 Spring Cloud Gateway 需要运行在提供的 Netty 运行时。它不能在传统的 Servlet 容器中工作&#xff0c;也不能在构建为 WAR 时工作。WebFlux 使用了异步非阻塞的编程模型&#xff0c;相较于传统的 MVC Servlet 需要理解和适应新的编程范式和响应…