Thread: dba_enabled_traces and sql_trace column in v$session never gets updated


Permlink Replies: 10 - Pages: 1 - Last Post: Dec 29, 2006 11:02 PM Last Post By: TongucY
TongucY

Posts: 1,246
Registered: 05/01/00
dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 28, 2006 3:24 AM
Click to report abuse...   Click to reply to this thread Reply
Tried this in both Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
and Oracle Database 10g Express Edition Release 10.2.0.1.0

i tried three different ways to produce sql trace and in all of them i can see the trc file in my user_dump_dest;

- dbms_monitor.session_trace_enable
- DBMS_SYSTEM.SET_EV
- ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 8';

But dba_enabled_traces view and sql_trace, sql_trace_waits, sql_trace_binds columns in v$session never gets updated with the information for that session traceing is enabled.

Anyone experienced something like this? I am suspect this maybe a bug.

Best regards,
Thank you.
Tonguç
TongucY

Posts: 1,246
Registered: 05/01/00
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 28, 2006 11:49 PM   in response to: TongucY in response to: TongucY
Click to report abuse...   Click to reply to this thread Reply
I opened a SR on metalink Number 6060279.992, and metalink note Title: Tracing Enhancements in 10g is shared with me. This article explains the new tracing possibilities in 10g with the package dbms_monitor and give some examples how you can use them and there is no new information that is not given in the 10g Performance Tuning Guide.

This one was really strange..

Best reagrds,
Tonguc
orafad

Posts: 5,751
Registered: 02/04/99
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 1:46 AM   in response to: TongucY in response to: TongucY
Click to report abuse...   Click to reply to this thread Reply
Write up a small test case and ask them to try it and see if it reproduces.
TongucY

Posts: 1,246
Registered: 05/01/00
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 2:53 AM   in response to: orafad in response to: orafad
Click to report abuse...   Click to reply to this thread Reply
Thank you for your interest Mr.Adolfsson,

In deed I did provide the test case as follows;

SELECT sid, serial#, sql_trace, sql_trace_waits, sql_trace_binds
FROM v$session
WHERE username = 'SYS'
AND osuser = 'TURKCELL\TCHASYILMAZ';

set serveroutput on
execute dbms_session.set_identifier('tong');
EXECUTE DBMS_MONITOR.CLIENT_ID_STAT_ENABLE('tong');
BEGIN
dbms_monitor.session_trace_enable(session_id => 38,
serial_num => 3,
waits => TRUE,
binds => FALSE);
END;
/
commit ;

SELECT sid, serial#, sql_trace, sql_trace_waits, sql_trace_binds
FROM v$session
WHERE username = 'SYS'
AND osuser = 'TURKCELL\TCHASYILMAZ';

SELECT * FROM dba_enabled_traces ;

EXECUTE DBMS_MONITOR.CLIENT_ID_STAT_DISABLE('tong');
BEGIN
dbms_monitor.session_trace_disable(session_id => 38,
serial_num => 3) ;
END;
/
commit ;

SELECT sid, serial#, sql_trace, sql_trace_waits, sql_trace_binds
FROM v$session
WHERE username = 'SYS'
AND osuser = 'TURKCELL\TCHASYILMAZ';
orafad

Posts: 5,751
Registered: 02/04/99
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 3:13 AM   in response to: TongucY in response to: TongucY
Click to report abuse...   Click to reply to this thread Reply
I couldnt resist trying it, a modified variant....

This is from 10.2.0.1 on my Windows XP laptop

SQL> ed
Wrote file afiedt.buf
 
  1  BEGIN
  2  dbms_monitor.session_trace_enable(session_id => 159,
  3  serial_num => 3,
  4  waits => TRUE,
  5  binds => FALSE);
  6* END;
SQL> / 
 
PL/SQL procedure successfully completed.
 
SQL> SELECT sid, serial#, sql_trace, sql_trace_waits, sql_trace_binds
  2  FROM v$session
  3  WHERE username = 'SYS'
  4  ;
 
       SID    SERIAL# SQL_TRAC SQL_T SQL_T
---------- ---------- -------- ----- -----
       159          3 ENABLED  TRUE  FALSE
 
SQL> SELECT * FROM dba_enabled_traces ;
 
no rows selected
 
SQL> BEGIN
  2  dbms_monitor.session_trace_disable(session_id => 159);
  3  end;
  4  / 
 
PL/SQL procedure successfully completed.
 
SQL> SELECT sid, serial#, sql_trace, sql_trace_waits, sql_trace_binds
  2  FROM v$session
  3  WHERE username = 'SYS'
  4  ;
 
       SID    SERIAL# SQL_TRAC SQL_T SQL_T
---------- ---------- -------- ----- -----
       159          3 DISABLED FALSE FALSE


As you can see I skipped the client identifier.

Message was edited by:
orafad
TongucY

Posts: 1,246
Registered: 05/01/00
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 6:11 AM   in response to: orafad in response to: orafad
Click to report abuse...   Click to reply to this thread Reply
I have no idea what is going on here, maybe a new year suprise for me :) I am happy it does work for you;

-- Enterprise Edition Release 10.2.0.2.0 and DBA role granted and platform_name Solaristm OE (64-bit)
SET SERVEROUTPUT ON
BEGIN
dbms_output.put_line('VERSION ' || dbms_db_version.version);
dbms_output.put_line('RELEASE ' || dbms_db_version.release);
END;
/

BEGIN
dbms_monitor.session_trace_enable(session_id => 98,
serial_num => 21659,
waits => TRUE,
binds => FALSE);
END;
/

SELECT sid, serial#, sql_trace, sql_trace_waits, sql_trace_binds
FROM v$session
WHERE sid = 98 and SERIAL# = 21659 ;

SELECT * FROM dba_enabled_traces ;

Output :

VERSION 10
RELEASE 2

PL/SQL procedure successfully completed

PL/SQL procedure successfully completed

SID SERIAL# SQL_TRACE SQL_TRACE_WAITS SQL_TRACE_BINDS


----------
---------------
98 21659 DISABLED FALSE FALSE

TRACE_TYPE PRIMARY_ID QUALIFIER_ID1 QUALIFIER_ID2 WAITS BINDS INSTANCE_NAME

----------------------------------------------------------------
--------------------------------
-----

Also tried on my laptop at XE like you did;

-- Express Edition Release 10.2.0.1.0 and DBA role granted and platform_name Microsoft Windows IA (32-bit)
SET SERVEROUTPUT ON
BEGIN
dbms_output.put_line('VERSION ' || dbms_db_version.version);
dbms_output.put_line('RELEASE ' || dbms_db_version.release);
END;
/

BEGIN
dbms_monitor.session_trace_enable(session_id => 38,
serial_num => 3,
waits => TRUE,
binds => FALSE);
END;
/

SELECT sid, serial#, sql_trace, sql_trace_waits, sql_trace_binds
FROM v$session
WHERE sid = 38 and SERIAL# = 3 ;

SELECT * FROM dba_enabled_traces ;

Output :

VERSION 10
RELEASE 2

PL/SQL procedure successfully completed

PL/SQL procedure successfully completed

SID SERIAL# SQL_TRACE SQL_TRACE_WAITS SQL_TRACE_BINDS


----------
---------------
38 3 DISABLED FALSE FALSE

TRACE_TYPE PRIMARY_ID QUALIFIER_ID1 QUALIFIER_ID2 WAITS BINDS INSTANCE_NAME

----------------------------------------------------------------
--------------------------------
-----

Best regards, and a happy new year sir.
Tonguç
orafad

Posts: 5,751
Registered: 02/04/99
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 6:52 AM   in response to: TongucY in response to: TongucY
Click to report abuse...   Click to reply to this thread Reply
Are you enabling the trace in the same or from a different session to the one you are tracing? If you are enabling the trace from another session, you may need to issue some sql in the traced session before checking v$session. Also, have you tried waiting a little while before querying v$session?
orafad

Posts: 5,751
Registered: 02/04/99
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 6:52 AM   in response to: TongucY in response to: TongucY
Click to report abuse...   Click to reply to this thread Reply
...and Happy new year to you too :)
TongucY

Posts: 1,246
Registered: 05/01/00
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 9:04 AM   in response to: orafad in response to: orafad
Click to report abuse...   Click to reply to this thread Reply
Ohhh this was good, thank you very much for your time sir. I am too tired really, when I entered this from the session I traced;

HR on 29/12/2006 18:54:54 at XE > select user, sysdate from dual ;

USER SYSDATE

-------------------
HR 29/12/2006 18:56:13

SYS on 29/12/2006 at XE > SELECT sid, serial#, sql_trace, sql_trace_waits, sql_t
race_binds
2 FROM v$session
3 WHERE sid = 74 and SERIAL# = 24 ;

SID SERIAL# SQL_TRAC SQL_T SQL_T


----------
-----
74 24 ENABLED TRUE FALSE

I finally saw v$session being updated :) But this view is still empty, do you have any recommendation sir;

SYS on 29/12/2006 at XE > SELECT * FROM dba_enabled_traces ;

no rows selected

Metalink mentioned "This tracing state is not persistent across a database shutdown and you see no entry in DBA_ENABLED_TRACES." this but there is no shutdown happening during this tracing.

Kind regards,
Tonguç

orafad

Posts: 5,751
Registered: 02/04/99
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 2:43 PM   in response to: TongucY in response to: TongucY
Click to report abuse...   Click to reply to this thread Reply
Well, I think the following will clear up a few things...

I left out the client id and stat enable bits from your test case before, without even thinking about why I did that. Until now that is :)

First there's the statistics (that oracle gathers all the time), which you from 10.x can "scope" in on not only session or system level but also client id, module, action and service:

SQL> select sid,username,client_identifier from v$session where username='SYS';
 
       SID USERNAME                       CLIENT_IDENT
---------- ------------------------------ ------------
       159 SYS
 
SQL> exec dbms_session.set_identifier('some.id');
 
PL/SQL procedure successfully completed.
 
SQL> select sid,username,client_identifier from v$session where username='SYS';
 
       SID USERNAME                       CLIENT_IDENT
---------- ------------------------------ ------------
       159 SYS                            some.id
 
SQL> select * from v$client_stats;
 
no rows selected
 
SQL> exec dbms_monitor.client_id_stat_enable('some.id');
 
PL/SQL procedure successfully completed.
 
SQL> select client_identifier,stat_name,value from v$client_stats;
 
CLIENT_IDENT STAT_NAME                           VALUE
------------ ------------------------------ ----------
some.id      user calls                              2
some.id      DB time                               314
some.id      DB CPU                                314
some.id      parse count (total)                     1
some.id      parse time elapsed                     67
some.id      execute count                           2
some.id      sql execute elapsed time              115
some.id      opened cursors cumulative               1
...
27 rows selected.
 
SQL> select sysdate from dual;
 
SYSDATE
----------
2006-12-29
 
SQL>
SQL> select client_identifier,stat_name,value from v$client_stats;
 
CLIENT_IDENT STAT_NAME                           VALUE
------------ ------------------------------ ----------
some.id      user calls                             11
some.id      DB time                              1582
some.id      DB CPU                               1582
some.id      parse count (total)                     3
some.id      parse time elapsed                    226
some.id      execute count                           9
some.id      sql execute elapsed time              901
some.id      opened cursors cumulative               3
...
27 rows selected.
 
SQL> exec dbms_monitor.client_id_stat_disable('some.id');
 
PL/SQL procedure successfully completed.
 
SQL> select * from v$client_stats;
 
no rows selected

Another tool we have that's now also "scopable" (by client id, etc.) is Sql trace. For example, you can trace across sessions without tracing the entire server. Using the same id as in above example:

SQL> select * from dba_enabled_traces;
 
no rows selected
 
SQL> exec dbms_monitor.client_id_trace_enable(client_id => 'some.id',waits => true);
 
PL/SQL procedure successfully completed.
 
SQL> select * from dba_enabled_traces;
 
TRACE_TYPE
---------------------
PRIMARY_ID
----------------------------------------------------------------
QUALIFIER_ID1
------------------------------------------------
QUALIFIER_ID2                    WAITS BINDS INSTANCE_NAME
-------------------------------- ----- ----- ----------------
CLIENT_ID
some.id
 
                                 TRUE  FALSE
 
 
SQL> exec dbms_monitor.client_id_trace_disable('some.id');
 
PL/SQL procedure successfully completed.
 
SQL> select * from dba_enabled_traces;
 
no rows selected


Since you got no rows from the view, I guess dba_enabled_traces does not include e.g. session level trace.

You come up with very good questions, that makes for a good excercise, right before new years and all ;) Hope stats vs tracing is a bit clearer now!

Message was edited by:
orafad
TongucY

Posts: 1,246
Registered: 05/01/00
Re: dba_enabled_traces and sql_trace column in v$session never gets updated
Posted: Dec 29, 2006 11:02 PM   in response to: orafad in response to: orafad
Click to report abuse...   Click to reply to this thread Reply
Mr.Adolfsson this was like an Oracle education center workshop for me, even more beneficial. It is great to meet you and I really thank you for your efforts and examples, everything is clear and I understood the topic now :)

Kind regards,
Tonguç

ps: I believe you also helped Oracle support to understand the topic :)
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums