search
HomeDatabaseMysql TutorialNDMCDB数据库hang住故障分析-cursor:pinSwaitonX

问题描述: 上午刚刚到办公室,就有监控人员邮件反馈,昨晚NDMCDB407数据库被重启过,让我分析一下数据库重启的原因。由于昨晚业务有版本上线,所以短信警告关闭了,所以没有短信下发到我手机上,而且故障时相关人员也没有通知到我。 1 检查alert日志 从aler

问题描述:

上午刚刚到办公室,就有监控人员邮件反馈,昨晚NDMCDB407数据库被重启过,让我分析一下数据库重启的原因。由于昨晚业务有版本上线,所以短信警告关闭了,所以没有短信下发到我手机上,而且故障时相关人员也没有通知到我。

1 检查alert日志

从alert日志中,可以看到,先是在03:29时有一个job运行失败了:
Fri Aug 22 03:29:29 2014
Errors in file/opt/oracle/diag/rdbms/ndmcdb/NDMCDB/trace/NDMCDB_j000_28856.trc:
ORA-12012: error on auto execute of job 31
ORA-04023: ObjectNDMC.DELETE_ANONY_RSHARE_INFO could not be validated or authorized
ORA-06512: at "NDMC.PROC_NDMC_CANCEL_OPEN",line 5
ORA-06512: at line 1
然后在03:49时,出现了连接超时失败,而且一直持续到05:00:08:
Fri Aug 22 03:49:43 2014
***********************************************************************
 
Fatal NI connect error 12170.
 
 VERSION INFORMATION:
       TNS for Linux: Version 11.1.0.7.0 - Production
       Oracle Bequeath NT Protocol Adapter for Linux: Version 11.1.0.7.0 -Production
       TCP/IP NT Protocol Adapter for Linux: Version 11.1.0.7.0 - Production
 Time: 22-AUG-2014 03:49:43
 Tracing not turned on.
  Tnserror struct:
   ns main err code: 12535
   
TNS-12535: TNS:operation timed out
   ns secondary err code: 12606
   nt main err code: 0
   nt secondary err code: 0
   nt OS err code: 0
 Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.130.87)(PORT=36628))
WARNING: inbound connection timed out(ORA-3136)
Fri Aug 22 03:49:44 2014
……
而且出现了连接数耗尽了:
Fri Aug 22 03:49:50 2014
ORA-00020: maximum number of processes 0exceeded
   ns secondary err code: 12560
   ns secondary err code: 12560
   ns main err code: 12537
Fri Aug 22 03:49:50 2014
……
Fri Aug 22 03:51:48 2014
 
***********************************************************************
 
Fatal NI connect error 12537, connectingto:
 (LOCAL=NO)
 
 VERSION INFORMATION:
       TNS for Linux: Version 11.1.0.7.0 - Production
       Oracle Bequeath NT Protocol Adapter for Linux: Version 11.1.0.7.0 -Production
       TCP/IP NT Protocol Adapter for Linux: Version 11.1.0.7.0 - Production
 Time: 22-AUG-2014 03:51:48
 Tracing not turned on.
  Tnserror struct:
   ns main err code: 12537
   
TNS-12537: TNS:connection closed
ns secondaryerr code: 12560
   nt main err code: 0
   nt secondary err code: 0
   nt OS err code: 0
ORA-609 : opiodr aborting process unknownospid (30476_47044991385184)
Fri Aug 22 04:14:15 2014
ORA-28 : opiodr aborting process unknownospid (24925_46986315964000)
Fri Aug 22 04:16:27 2014
ORA-28 : opiodr aborting process unknownospid (22475_47013891882592)
Fri Aug 22 04:16:28 2014
ORA-28 : opiodr aborting process unknownospid (21356_47116835528288)
Fri Aug 22 04:16:29 2014
ORA-28 : opiodr aborting process unknownospid (24947_47774766210656)
ORA-28 : opiodr aborting process unknownospid (14958_47053435166304)
……
Fri Aug 22 05:00:05 2014
ORA-28 : opiodr aborting process unknownospid (25765_46941307182688)
Fri Aug 22 05:00:08 2014
ORA-28 : opiodr aborting process unknownospid (4949_47396524895840)
于是在05:04数据库被关闭,从日志来看,这是正常关闭的,初步怀疑是人为关闭或是VCS双机自动将数据库关闭了:
Fri Aug 22 05:04:10 2014
Stopping background process SMCO
Stopping background process FBDA
Shutting down instance: further logonsdisabled
Fri Aug 22 05:04:12 2014
Stopping background process CJQ0
Stopping background process QMNC
Stopping background process MMNL
Stopping background process MMON
Shutting down instance (immediate)
License high water mark = 1220
Stopping Job queue slave processes, flags =7
Fri Aug 22 05:04:20 2014
Waiting for Job queue slaves to complete
Job queue slave processes stopped
Fri Aug 22 05:09:11 2014
License high water mark = 1220
USER (ospid: 25110): terminating theinstance
Termination issued to instance processes.Waiting for the processes to exit
Fri Aug 22 05:09:21 2014
Instance termination failed to kill one ormore processes
Instance terminated by USER, pid = 25110

2 检查messages日志

大概在05:03:51时,人为的想将双机切换到备机中:

Aug 22 05:03:51 NDMCDB11 user_cmd:2014-08-22 05:03:51 hagrp -switch RCS_DB_SG -to system by root from [oraclepts/9 Aug 22 04:29 (192.168.128.142)]
Aug 22 05:04:01 NDMCDB11/usr/sbin/cron[15348]: (root) CMD (su - root -c'/opt/watchdog/watchdog_schedule -n OS,oracle' >/dev/null 2>&1)
Aug 22 05:04:01 NDMCDB11 su: (to root) rooton none
Aug 22 05:04:03 NDMCDB11 su: (to oracle)root on none
Aug 22 05:04:09 NDMCDB11 user_cmd:2014-08-22 05:04:09 hagrp -switch RCS_DB_SG -to NDMCDB12 by root from [oraclepts/9 Aug 22 04:29 (192.168.128.142)]
Aug 22 05:04:09 NDMCDB11 su: (to oracle)root on none 

但双机切换失败,最后是直接将双机停止,重启VCS:

Aug 22 05:06:18 NDMCDB11 user_cmd:2014-08-22 05:06:18 hastop -all by root from [oracle pts/9 Aug 22 04:29(192.168.128.142)]
……
Aug 22 05:07:02 NDMCDB11 user_cmd:2014-08-22 05:07:02 hastat by root from [oracle pts/9 Aug 22 04:29(192.168.128.142)]

所以,到这里就已经确定,数据库这所以重启了,完全是由于人为将VCS集群重启引起的。那么为什么要VCS群集重启呢?数据库到底有没有问题呢?再来看看。

最后,经向升级人员操作确认,在升级时,有一个存储过程需要跑,但执行后,数据库基本响应就非常慢了,一直运行到3:29左右,人为cancel掉了,所以这也就是为什么会出现这样的报错了:

Fri Aug 22 03:29:29 2014
Errors in file/opt/oracle/diag/rdbms/ndmcdb/NDMCDB/trace/NDMCDB_j000_28856.trc:
ORA-12012: error on auto execute of job 31
ORA-04023: ObjectNDMC.DELETE_ANONY_RSHARE_INFO could not be validated or authorized
ORA-06512: at"NDMC.PROC_NDMC_CANCEL_OPEN", line 5
ORA-06512: at line 1 

3 查看系统负载

CPU负载:

\

 

内存负载:

\

可见,系统在3:49左右,出现了CPU及内存均被耗尽的情况,这个时间段,刚好数据库出现了大量连接超时失败,甚至是出现了连接数超过阀值:

Fri Aug 22 03:49:50 2014
ORA-00020: maximum number of processes 0exceeded
   ns secondary err code: 12560
   ns secondary err code: 12560
   ns main err code: 12537
Fri Aug 22 03:49:50 2014

4 分析AWR

\

从这里看,数据库在2点到3点时,已经非常的繁忙,但从之前有系统负载来看,2点到3点时,CPU及内存使用率都不算很高的。接着看:

\

指标都没有什么特别高的。

\

从top 5 event中,看到了有大量的cursor: pin S wait on X等待,可见出现mutex争用,但通常这只是表象而已,并非根因。

\

绝大部分时间都在做SQL的解析,而且解析还失败了,这就是数据库hang住的根因。正常来说,一个数据库的绝大部分时间应该是用于SQL的执行,所以这个是占用最多时间的:sql execute elapsedtime等。

\

不存在较高的versioncount。

那么数据库什么时候出现的不停解析SQL,并且解析失败了呢?

查了DBA_HIST_ACTIVE_SESS_HISTORY,分析了下历史会话信息,发现在02:57:00至03:00:00出现的问题:

\

经过确认,恰巧就是执行存储过程的时间点左右。

至此,数据库从3:00开始,已经是不正常的,数据库不停的在解析SQL,SQL都还没有到执行这一步,数据库已经处于无响应的状态,连接会话都被阻塞住了,直到连接数达到了最大连接数,最后被升级操作人员重启了VCS集群。

5 分析结论

(1)数据库down机主要还是人为进行了VCS切换失败后,进行了VCS重启操作引起。

(2)这套数据库故障的根因,还是为什么数据库在2:58左右时出现解析SQL失败上。从目前的日志分析来看,看不出是什么原因。

-- Bosco ---- END ----
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are the different storage engines available in MySQL?What are the different storage engines available in MySQL?Apr 26, 2025 am 12:27 AM

MySQLoffersvariousstorageengines,eachsuitedfordifferentusecases:1)InnoDBisidealforapplicationsneedingACIDcomplianceandhighconcurrency,supportingtransactionsandforeignkeys.2)MyISAMisbestforread-heavyworkloads,lackingtransactionsupport.3)Memoryengineis

What are some common security vulnerabilities in MySQL?What are some common security vulnerabilities in MySQL?Apr 26, 2025 am 12:27 AM

Common security vulnerabilities in MySQL include SQL injection, weak passwords, improper permission configuration, and unupdated software. 1. SQL injection can be prevented by using preprocessing statements. 2. Weak passwords can be avoided by forcibly using strong password strategies. 3. Improper permission configuration can be resolved through regular review and adjustment of user permissions. 4. Unupdated software can be patched by regularly checking and updating the MySQL version.

How can you identify slow queries in MySQL?How can you identify slow queries in MySQL?Apr 26, 2025 am 12:15 AM

Identifying slow queries in MySQL can be achieved by enabling slow query logs and setting thresholds. 1. Enable slow query logs and set thresholds. 2. View and analyze slow query log files, and use tools such as mysqldumpslow or pt-query-digest for in-depth analysis. 3. Optimizing slow queries can be achieved through index optimization, query rewriting and avoiding the use of SELECT*.

How can you monitor MySQL server health and performance?How can you monitor MySQL server health and performance?Apr 26, 2025 am 12:15 AM

To monitor the health and performance of MySQL servers, you should pay attention to system health, performance metrics and query execution. 1) Monitor system health: Use top, htop or SHOWGLOBALSTATUS commands to view CPU, memory, disk I/O and network activities. 2) Track performance indicators: monitor key indicators such as query number per second, average query time and cache hit rate. 3) Ensure query execution optimization: Enable slow query logs, record and optimize queries whose execution time exceeds the set threshold.

Compare and contrast MySQL and MariaDB.Compare and contrast MySQL and MariaDB.Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

How does MySQL's licensing compare to other database systems?How does MySQL's licensing compare to other database systems?Apr 25, 2025 am 12:26 AM

MySQL uses a GPL license. 1) The GPL license allows the free use, modification and distribution of MySQL, but the modified distribution must comply with GPL. 2) Commercial licenses can avoid public modifications and are suitable for commercial applications that require confidentiality.

When would you choose InnoDB over MyISAM, and vice versa?When would you choose InnoDB over MyISAM, and vice versa?Apr 25, 2025 am 12:22 AM

The situations when choosing InnoDB instead of MyISAM include: 1) transaction support, 2) high concurrency environment, 3) high data consistency; conversely, the situation when choosing MyISAM includes: 1) mainly read operations, 2) no transaction support is required. InnoDB is suitable for applications that require high data consistency and transaction processing, such as e-commerce platforms, while MyISAM is suitable for read-intensive and transaction-free applications such as blog systems.

Explain the purpose of foreign keys in MySQL.Explain the purpose of foreign keys in MySQL.Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.