V$Session_wait or V$Session 总结

The view V$Session_wait can show useful information about what a session is waiting for.
Multiple selects from this view can indicate if a session is moving or not.
When wait_time=0 the session is waiting , any other value indicates CPU activity.


v$session_wait is often misinterpreted.

Often people will assume we are waiting because see an event and seconds_in_wait is rising. It should be remembered that seconds_in_wait only applies to a current wait if wait_time =0 , otherwise it is actually "seconds since the last wait completed".

 

The other column of use to clear up the misinterpretation is state which will be WAITING if we are waiting and WAITED% if we are no longer waiting.

 

Each wait event has up to 3 additional parameters giving more information about the wait. Pn TEXT tells you what Pn represents.

 

P1RAW , P2RAW , and P3RAW display the same values as the P1 , P2 , and P3 columns, except that the numbers are displayed in hexadecimal.

 

The WAIT_TIME column contains a value of -2 on platforms that do not support a fast timing mechanism when <<Parameter:TIMED_STATISTICS>> is set to FALSE . Set it to TRUE to get meaningful figures.

WAIT_TIME=-2是因为将 Parameter:TIMED_STATISTICS设置为FALSE

 

The WAIT_TIME column should only be 0 if the session is currently waiting for EVENT .

However, due to Bug:2117360 a value of "0" may show in Oracle9i when a session has actually finished waiting.

Use the value of the STATE column to check that the session is actually "WAITING " as this column shows the correct state.


 

 

Column Vers Datatype Description
SID  NUMBER Session identifier.
Join to <<View:V$SESSION>> . SID
SEQ#   NUMBER Sequence number that uniquely identifies this wait. Incremented for each wait.
EVENT   VARCHAR2(64) Resource or event for which the session is waiting.
P1TEXT   VARCHAR2 Description of first wait-event parameter (P1)
P1   NUMBER First wait-event parameter in decimal
P1RAW   RAW(4 | 8) First wait-event parameter in hexadecimal .
Column size depends on platform . 32bit = RAW(4), 64bit=RAW(8)
P2TEXT   VARCHAR2 Description of second parameter
P2   NUMBER Second parameter in decimal
P2RAW   RAW(4 | 8) Second parameter in hexadecimal
P3TEXT   VARCHAR2 Description of third parameter
P3   NUMBER Third additional parameter in decimal
P3RAW   RAW(4 | 8) Third additional parameter in hexadecimal
WAIT_TIME   NUMBER A nonzero value is the session's last wait time. A zero value means the session is currently waiting (except in Oracle 9.0 where Bug:2117360 occurs).
  • 0 - the session is currently waiting
  • -2 - duration of last wait is unknown
  • -1 - last wait was <1/100th of a second in duration
  • >0 - duration of last wait in 1/100th second units (10mS)
  • <-2 - The internal time has probably wrapped
SECONDS_IN_WAIT 7.3+ NUMBER When WAIT_TIME = 0 then this shows the number of seconds spent in the current wait (3 second granularity on most platforms / versions).
This value should NOT reset on events with timeouts.
Eg: The "enqueue" waitevent times out and re-waits (SEQ# increments) but SECONDS_IN_WAIT shows the cumulative time in wait.
Unfortunately this column does get reset in versions 9201-9203 inclusive due to Bug:2803772 .

When WAIT_TIME != 0 this column shows the number of seconds since the start of the last wait.
STATE 7.3+ VARCHAR2 Wait state:
  • WAITING (the session is currently waiting)
  • WAITED UNKNOWN TIME (duration of last wait is unknown)
  • WAITED SHORT TIME (last wait <1/100th of a second)
  • WAITED KNOWN TIME (WAIT_TIME = duration of last wait)

     

WAIT_TIME_MICRO 11.1+ NUMBER A nonzero value is the session's last wait time in microseconds, giving more precision than WAIT_TIME which is in 1/100th seconds
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
分析一下下面这段代码while(1) { revents = 0; #ifndef DISABLE_LIBSSH if (session->ssh_chan != NULL) { /* we are getting data from libssh's channel */ status = ssh_channel_poll_timeout(session->ssh_chan, timeout, 0); if (status > 0) { revents = POLLIN; } } else #endif #ifdef ENABLE_TLS if (session->tls != NULL) { /* we are getting data from TLS session using OpenSSL */ fds.fd = SSL_get_fd(session->tls); fds.events = POLLIN; fds.revents = 0; status = poll(&fds, 1, timeout); revents = (unsigned long int) fds.revents; } else #endif if (session->fd_input != -1) { /* we are getting data from standard file descriptor */ fds.fd = session->fd_input; fds.events = POLLIN; fds.revents = 0; status = poll(&fds, 1, timeout); revents = (unsigned long int) fds.revents; } else { ERROR("Invalid session to receive data."); return (NC_MSG_UNKNOWN); } /* process the result */ if (status == 0) { /* timed out */ DBG_UNLOCK("mut_channel"); pthread_mutex_unlock(session->mut_channel); return (NC_MSG_WOULDBLOCK); } else if (((status == -1) && (errno == EINTR)) #ifndef DISABLE_LIBSSH || (status == SSH_AGAIN) #endif ) { /* poll was interrupted */ continue; } else if (status < 0) { /* poll failed - something wrong happend, close this socket and wait for another request */ DBG_UNLOCK("mut_channel"); pthread_mutex_unlock(session->mut_channel); #ifndef DISABLE_LIBSSH if (status == SSH_EOF) { emsg = "end of file"; } else if (!session->ssh_chan) { emsg = strerror(errno); } else if (session->ssh_sess) { emsg = ssh_get_error(session->ssh_sess); } else { emsg = "description not available"; } #else emsg = strerror(errno); #endif WARN("Input channel error (%s)", emsg); nc_session_close(session, NC_SESSION_TERM_DROPPED); if (nc_info) { pthread_rwlock_wrlock(&(nc_info->lock)); nc_info->stats.sessions_dropped++; pthread_rwlock_unlock(&(nc_info->lock)); } return (NC_MSG_UNKNOWN); } /* status > 0 */ /* check the status of the socket */ /* if nothing to read and POLLHUP (EOF) or POLLERR set */ if ((revents & POLLHUP) || (revents & POLLERR)) { /* close client's socket (it's probably already closed by client */ DBG_UNLOCK("mut_channel"); pthread_mutex_unlock(session->mut_channel); ERROR("Input channel closed"); nc_session_close(session, NC_SESSION_TERM_DROPPED); if (nc_info) { pthread_rwlock_wrlock(&(nc_info->lock)); nc_info->stats.sessions_dropped++; pthread_rwlock_unlock(&(nc_info->lock)); } return (NC_MSG_UNKNOWN); } /* we have something to read */ break; }
最新发布
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值