<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tanel Poder&#039;s blog: IT &#38; Mobile for Geeks and Pros &#187; Uncategorized</title>
	<atom:link href="http://blog.tanelpoder.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tanelpoder.com</link>
	<description>Oracle, Exadata, Performance, Troubleshooting - Mobile Life and Productivity.</description>
	<lastBuildDate>Thu, 02 Feb 2012 21:38:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Expert Oracle Exadata virtual conference</title>
		<link>http://blog.tanelpoder.com/2011/07/22/expert-oracle-exadata-virtual-conference/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=expert-oracle-exadata-virtual-conference</link>
		<comments>http://blog.tanelpoder.com/2011/07/22/expert-oracle-exadata-virtual-conference/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 06:51:00 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[exadata]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/2011/07/22/expert-oracle-exadata-virtual-conference/</guid>
		<description><![CDATA[Today is the last day for getting the early bird&#8217;s rate! http://blog.tanelpoder.com/seminar/expert-oracle-exadata-virtual-conference/ Also, our book will be out on Monday!]]></description>
			<content:encoded><![CDATA[<p>Today is the last day for getting the early bird&#8217;s rate!</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vc2VtaW5hci9leHBlcnQtb3JhY2xlLWV4YWRhdGEtdmlydHVhbC1jb25mZXJlbmNlLw==">http://blog.tanelpoder.com/seminar/expert-oracle-exadata-virtual-conference/</a></p>
<p>Also, our book will be out on Monday!</p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1473" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2011/07/22/expert-oracle-exadata-virtual-conference/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Exadata CAN do smart scans on bitmap indexes</title>
		<link>http://blog.tanelpoder.com/2011/03/15/exadata-can-do-smart-scans-on-bitmap-indexes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=exadata-can-do-smart-scans-on-bitmap-indexes</link>
		<comments>http://blog.tanelpoder.com/2011/03/15/exadata-can-do-smart-scans-on-bitmap-indexes/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 22:27:43 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Exadata]]></category>
		<category><![CDATA[Oracle 11gR2]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/2011/03/15/exadata-can-do-smart-scans-on-bitmap-indexes/</guid>
		<description><![CDATA[As I&#8217;m finishing up a performance chapter for the Exadata book (a lot of work!), I thought to take a quick break and write a blog entry. This is not really worth putting into my Oracle Exadata Performance series (which so far has only 1 article in it anyway) .. so this is a little [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m finishing up a performance chapter for the Exadata book (a lot of work!), I thought to take a quick break and write a blog entry.</p>
<p>This is not really worth putting into my <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAxMS8wMy8xMy9vcmFjbGUtZXhhZGF0YS1wZXJmb3JtYW5jZS1zZXJpZXMtcGFydC0xLXNob3VsZC1pLXVzZS1odWdlcGFnZXMtb24tbGludXgtZGF0YWJhc2Utbm9kZXMv" target=\"_blank\">Oracle Exadata Performance series</a> (which so far has only 1 article in it anyway) .. so this is a little stand-alone article &#8230;</p>
<p>Everybody knows that the Exadata smart scan can be used when scanning <strong>tables</strong> (and table partitions). You should also know that smart scan can be used with fast full scan on Oracle B-tree indexes (a fast full scan on an index segment is just like a full table scan, only on the index segment (and ignoring branch blocks)).</p>
<p>For some reason there&#8217;s a (little) myth circulating that smart scans aren&#8217;t used for scanning bitmap indexes.</p>
<p>So, here&#8217;s evidence, that smart scan <strong>can</strong> be used when scanning bitmap indexes:</p>
<pre>SQL&gt; select /*+ tanel3 */ count(*) from t1 where owner like '%XYZXYZ%';

...

Plan hash value: 39555139

-----------------------------------------------------------------------------------
| Id  | Operation                             | Name        | E-Rows | Cost (%CPU)|
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                      |             |        |   505 (100)|
|   1 |  SORT AGGREGATE                       |             |      1 |            |
|   2 |   BITMAP CONVERSION COUNT             |             |    400K|   505   (0)|
|*  3 |    BITMAP INDEX STORAGE FAST FULL SCAN| BI_T1_OWNER |        |            |
-----------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - storage(("OWNER" LIKE '%XYZXYZ%' AND "OWNER" IS NOT NULL))
       filter(("OWNER" LIKE '%XYZXYZ%' AND "OWNER" IS NOT NULL))</pre>
<p>So, as you see the execution plan sure shows a FAST FULL SCAN on a BITMAP INDEX segment, which happens to be on Exadata STORAGE.</p>
<p>Also, you see a storage() predicate applied on the line 3 of the execution plan, which means that Oracle will attempt to use a smart scan predicate offload &#8211; but this can&#8217;t always be done!</p>
<p>So, you can&#8217;t really determine whether a smart scan happened during execution just by looking into the execution plan, you should really check some V$SESSION statistics too. That&#8217;s where my <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXNjcmlwdHMtYW5kLXRvb2xzL3Nlc3Npb24tc25hcHBlcg==" target=\"_blank\">Snapper script</a> becomes handy.</p>
<p>I started Snapper on my session just before running the above query. The &#8220;smart table scan&#8221; and &#8220;smart index scan&#8221; performance counters are updated right after Oracle has opened the segment header and determines, from the number of blocks in the segment, whether to call the smart scan codepath or not. In other words, the smart scan counters are inremented in the beginning of the segment scan.</p>
<p>The output is following (some irrelevant counters are stripped for brevity):</p>
<pre>

@snapper all 5 1 "301"
Sampling SID 301 with interval 5 seconds, taking 1 snapshots...
setting stats to all due to option = all

-- Session Snapper v3.52 by Tanel Poder @ E2SN ( http://tech.e2sn.com )

-------------------------------------------------------------------------------------------------------------------------------------
    SID, USERNAME  , TYPE, STATISTIC                                                 ,     HDELTA, HDELTA/SEC,    %TIME, GRAPH
-------------------------------------------------------------------------------------------------------------------------------------
    301, TANEL     , STAT, physical read total IO requests                           ,         13,        2.6,
    301, TANEL     , STAT, physical read total multi block requests                  ,          4,         .8,
    301, TANEL     , STAT, physical read requests optimized                          ,          1,         .2,
    301, TANEL     , STAT, physical read total bytes optimized                       ,      8.19k,      1.64k,
    301, TANEL     , STAT, physical read total bytes                                 ,      4.63M,     925.7k,
    301, TANEL     , STAT, cell physical IO interconnect bytes                       ,     10.02k,         2k,
    301, TANEL     , STAT, physical reads                                            ,        565,        113,
    301, TANEL     , STAT, physical reads cache                                      ,          1,         .2,
    301, TANEL     , STAT, physical reads direct                                     ,        564,      112.8,
    301, TANEL     , STAT, physical read IO requests                                 ,         13,        2.6,
    301, TANEL     , STAT, physical read bytes                                       ,      4.63M,     925.7k,
    301, TANEL     , STAT, db block changes                                          ,          1,         .2,
    301, TANEL     , STAT, cell physical IO bytes eligible for predicate offload     ,      4.62M,    924.06k,
    301, TANEL     , STAT, cell physical IO interconnect bytes returned by smart scan,      1.82k,      364.8,
    301, TANEL     , STAT, cell blocks processed by cache layer                      ,        564,      112.8,
    301, TANEL     , STAT, cell blocks processed by txn layer                        ,        564,      112.8,
    301, TANEL     , STAT, cell blocks processed by index layer                      ,        564,      112.8,
    301, TANEL     , STAT, cell blocks helped by minscn optimization                 ,        564,      112.8,
<strong>    301, TANEL     , STAT, cell index scans                                          ,          1,         .2,
</strong>    301, TANEL     , STAT, index fast full scans (full)                              ,          1,         .2,
    301, TANEL     , STAT, index fast full scans (direct read)                       ,          1,         .2,
    301, TANEL     , STAT, bytes sent via SQL*Net to client                          ,        334,       66.8,
    301, TANEL     , STAT, bytes received via SQL*Net from client                    ,        298,       59.6,
    301, TANEL     , STAT, SQL*Net roundtrips to/from client                         ,          2,         .4,
    301, TANEL     , STAT, cell flash cache read hits                                ,          1,         .2,
    301, TANEL     , TIME, hard parse elapsed time                                   ,     1.17ms,    233.8us,      .0%, |          |
    301, TANEL     , TIME, parse time elapsed                                        ,      1.5ms,    300.2us,      .0%, |          |
    301, TANEL     , TIME, DB CPU                                                    ,       11ms,      2.2ms,      .2%, |          |
    301, TANEL     , TIME, sql execute elapsed time                                  ,     82.2ms,    16.44ms,     1.6%, |@         |
    301, TANEL     , TIME, DB time                                                   ,    84.36ms,    16.87ms,     1.7%, |@         |
    301, TANEL     , WAIT, enq: KO - fast object checkpoint                          ,    16.18ms,     3.24ms,      .3%, |          |
    301, TANEL     , WAIT, gc cr grant 2-way                                         ,      223us,     44.6us,      .0%, |          |
    301, TANEL     , WAIT, gc current grant 2-way                                    ,      136us,     27.2us,      .0%, |          |
    301, TANEL     , WAIT, cell smart index scan                                     ,    56.04ms,    11.21ms,     1.1%, |@         |
    301, TANEL     , WAIT, SQL*Net message to client                                 ,        7us,      1.4us,      .0%, |          |
    301, TANEL     , WAIT, SQL*Net message from client                               ,      4.42s,   884.47ms,    88.4%, |@@@@@@@@@ |
    301, TANEL     , WAIT, cell single block physical read                           ,      541us,    108.2us,      .0%, |          |
    301, TANEL     , WAIT, events in waitclass Other                                 ,     2.22ms,    443.2us,      .0%, |          |
--  End of Stats snap 1, end=2011-03-13 19:36:31, seconds=5
</pre>
<p>As you see from the above &#8220;cell index scans&#8221; statistic &#8211; indeed one index segment was scanned using the cell smart scan method.</p>
<p>So, I would rather call this feature &#8220;smart segment scan&#8221; to reflect that smart scan can scan more than just tables&#8230;</p>
<p>I guess one of the reasons why few people have seen smart bitmap index scans in action is that (single-column) bitmap indexes tend to be small. Smaller than corresponding table segments and B-tree index segments. On partitioned tables they&#8217;re much more likely going to be under the &#8220;_small_table_threshold&#8221; calculation which is used for determining whether to do a direct path full segment scan or not (yes, the _small_table_threshold applies to fast full index scan and fast full bitmap index scan too, not just table scans). So, it&#8217;s likely that Oracle chooses to do a regular, buffered full bitmap segment scan and thus won&#8217;t even consider using smart scan (as smart scans require direct path reads).</p>
<p>By the way &#8211; the direct path read (or not) decision is done per segment &#8211; not per object (like a table or index). So if you have 10 partitions in a table (or index), half of them are large, half are smaller, then Oracle may end up using direct path reads (and smart scan) on 5 of them and buffered (dumb) scan on the other 5. If you run something like Snapper on the session, then you&#8217;d see the smart scan counters go up by 5 only. As written above, Oracle decides whether to do direct path reads (and smart scan) right after opening the header block of a segment (partition) and reading out how many blocks this partition&#8217;s segment has below HWM.</p>
<p>The above applied to <em>serial </em>direct path reads &#8211; the Parallel Execution slaves should always read using direct path mode, right? &#8230;. Wrong :)</p>
<p>Well, partially wrong&#8230; In 11.2.0.2, if the <strong>parallel_degree_policy</strong> = manual, then yes, PX slaves behave like usual and always force a direct path read (and try to use a smart scan). However, with parallel_degree_policy = AUTO, which is the future of PX auto-management, Oracle can decide to do a <em>buffered </em>parallel scan instead, again disabling the use of smart scan&#8230;</p>
<p>One more note &#8211; I didn&#8217;t say anything about whether you should or should not use (bitmap) indexes on Exadata, it&#8217;s an entirely different discussion. I just brought out that the smart scan <strong>is</strong> used for scanning table segments, B-tree index segments and bitmap index segments if conditions are right.</p>
<p>And in the end I have to say&#8230;. that even with this evidence you can&#8217;t be fully sure that a smart scan was used throughout the entire segment, but more about this in the book and perhaps in a later blog article. We have interesting times ahead ;-)</p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=864" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2011/03/15/exadata-can-do-smart-scans-on-bitmap-indexes/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Snapper 3.52 &#8211; With Oracle 9.2 support!</title>
		<link>http://blog.tanelpoder.com/2011/01/09/snapper-3-52-with-oracle-9-2-support-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=snapper-3-52-with-oracle-9-2-support-2</link>
		<comments>http://blog.tanelpoder.com/2011/01/09/snapper-3-52-with-oracle-9-2-support-2/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 19:28:00 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/2011/01/09/snapper-3-52-with-oracle-9-2-support-2/</guid>
		<description><![CDATA[As I promised last year, I have 2 christmas gifts for you. I have already forgotten what the other one was supposed to be :), but the first one is Snapper v3.52 which has (the much requested) Oracle 9.2 support! The syntax is the same, with Snapper you can now sample ASH-like data on Oracle [...]]]></description>
			<content:encoded><![CDATA[<p>As I promised last year, I have 2 christmas gifts for you. I have already forgotten what the other one was supposed to be :), but the first one is <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2ZpbGVzLmUyc24uY29tL3NjcmlwdHMvc25hcHBlci5zcWw=" target=\"_blank\">Snapper v3.52</a> which has (the much requested) <strong>Oracle 9.2 support!</strong></p>
<p>The syntax is the same, with Snapper you can now sample ASH-like data on Oracle 9.2 too. Instead of SQL_IDs it will display you SQL hash values:</p>
<pre><code>SQL&gt; @snapper <strong>ash,ash1=user+sql_id,ash2=sid+event</strong> 5 1 all
Sampling SID all with interval 5 seconds, taking 1 snapshots...

-- Session Snapper v3.52 by Tanel Poder @ E2SN ( http://tech.e2sn.com )

--------------------------------------------------
Active% | <strong>SQL_HASH_VAL</strong> | EVENT
--------------------------------------------------
    19% | <strong>867131449   </strong> | db file scattered read
    19% | 1458866975   | db file scattered read
    13% | 1267657304   | db file scattered read
     6% | 884811952    | ON CPU
     6% | 581825634    | db file scattered read
     3% | 867131449    | ON CPU
     3% | 1267657304   | ON CPU
     3% | 1866659945   | ON CPU
     3% | 1671194465   | db file scattered read
     3% | 3021169464   | ON CPU

------------------------------------------------
Active% | USERNAME             | SQL_ID
------------------------------------------------
    23% | SYSTEM               | 867131449
    19% | SYSTEM               | 1458866975
    16% | SYSTEM               | 1267657304
     6% | SYSTEM               | 581825634
     6% | SYSTEM               | 884811952
     3% | SYSTEM               | 1558333473
     3% | SYSTEM               | 1671194465
     3% | SYSTEM               | 1866659945
     3% | SYSTEM               | 1927486197
     3% | SYSTEM               | 2700565926

--------------------------------------------
Active% |    SID | EVENT
--------------------------------------------
    77% |     18 | db file scattered read
    19% |     18 | ON CPU
     3% |     18 | db file sequential read

--  End of ASH snap 1, end=2011-01-10 03:02:58, seconds=5, samples_taken=31

PL/SQL procedure successfully completed.

</code>
Other than the 9i change, the rest of the snapper is pretty much the same as earlier, with some minor bugfixes and additions.
</pre>
<p>You can download it from <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2ZpbGVzLmUyc24uY29tL3NjcmlwdHMvc25hcHBlci5zcWw=" target=\"_blank\">here</a>.</p>
<p><code> </code></p>
<p>If you want to get the most out of snapper, read this article here (and make sure you look inside the script!)</p>
<p><code></p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXNjcmlwdHMtYW5kLXRvb2xzL3Nlc3Npb24tc25hcHBlcg==" target=\"_blank\"><span style="color: #000000;">http://tech.e2sn.com/oracle-scripts-and-tools/session-snapper</span></a></li>
</ul>
<p>Note: Big thanks to <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21hcmN1c21vbm5pZy53b3JkcHJlc3MuY29tLw==" target=\"_blank\">Marcus Mönnig</a> who who wrote the additional 9i support code for Snapper first and <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuamFtZXlqb2huc3Rvbi5jb20v" target=\"_blank\">Jamey Johnston</a> for his additions (and myself for some final polishing fixes ;-)</p>
<p>Note2: I've agreed with Marcus that he could add Snapper into his free performance tool distribution in unchanged form, check out his <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21hcmN1c21vbm5pZy53b3JkcHJlc3MuY29tLzIwMTAvMTEvMDcvaW50cm9kdWN0b3J5LXdlYmNhc3QtZm9yLW11bWJhaS8=" target=\"_blank\">Mumbai tool</a> which could be useful for Oracle performance monitoring...</p>
<p><a class=\"performancingtags\" rel=\"tag\" href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2hub3JhdGkuY29tL3RhZy9zbmFwcGVy"></a></p>
<p></code></p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=821" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2011/01/09/snapper-3-52-with-oracle-9-2-support-2/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>How to CANCEL a query running in another session?</title>
		<link>http://blog.tanelpoder.com/2010/02/17/how-to-cancel-a-query-running-in-another-session/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-cancel-a-query-running-in-another-session</link>
		<comments>http://blog.tanelpoder.com/2010/02/17/how-to-cancel-a-query-running-in-another-session/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 04:14:54 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=628</guid>
		<description><![CDATA[Here&#8217;s a treat for Oracle geeks, hackers and maniacs out there&#8230; Update: As the beginning says, this article was meant as something interesting about Oracle&#8217;s internals and CTRL+C / OCICancel() handling. There&#8217;s a more practical way for canceling session calls if you are running Oracle Enterprise Edition and are currently using resource manager: You can [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a treat for Oracle geeks, hackers and maniacs out there&#8230;</p>
<p><em>Update: As the beginning says, this article was meant as something interesting about Oracle&#8217;s internals and CTRL+C / OCICancel() handling. There&#8217;s a more practical way for canceling session calls if you are running Oracle Enterprise Edition and are currently using resource manager:</em></p>
<p><em>You can set the consumer group for a session to CANCEL_SQL to cancel its current call:</em></p>
<p><em>DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS (<br />
<span style="font-style: normal;"><em><span style="font-style: normal;"><em><span style="font-style: normal;"><em>session_id IN NUMBER,<br />
<span style="font-style: normal;"><em><span style="font-style: normal;"><em><span style="font-style: normal;"><em><span style="font-style: normal;"><em>session_serial IN NUMBER,<br />
<span style="font-style: normal;"><em><strong>consumer_group</strong> IN VARCHAR2);</em></span></em></span></em></span></em></span></em></span></em></span></em></span></em></span></em></p>
<p><em>Thanks to commenter &#8220;null&#8221; for this info. Note that I haven&#8217;t tested how/whether this feature works correctly so there&#8217;s homework for you ;-)</em></p>
<p>I recently received a question about how to <em>cancel</em> queries running in another Oracle session, so that the session would not be killed, but would remain alive.</p>
<p>Well, there&#8217;s no supported way I can tell you, but thanks to how Oracle handles out-of-band breaks on Unix platforms, you can cancel database calls using an OS tool &#8211; kill.</p>
<p>Before we go on, here&#8217;s how query cancellation (pressing CTRL+C in sqlplus for example) works in Oracle:</p>
<ol>
<li>The user presses CTRL+C or clicks some button in App which runs OCICancel()</li>
<li>The client process sends an <em>urgent</em> TCP packet (which is a regular TCP packet with URG bit set) to the socket in the database server it is connected to</li>
<li>The server OS TCP stack receives the urgent TCP packet and sends URGENT signal to the process which owns the socket (the Oracle server process)</li>
<li>Unix interrupts whatever the current process was doing and calls the URGENT signal handler function (which Oracle has registered during process startup)</li>
<li>The urgent signal handler blindly assumes that the urgent signal has been received because user wants to cancel the query, stops the execution and returns back with an error: ORA-01013: user requested cancel of current operation</li>
</ol>
<p>So, if we can&#8217;t make our application send the break packet, OCICancel() then we can just send the SIGURG signal to the Oracle process just like the OS TCP stack would do when it receives the packet with urgent bit set.</p>
<p>Here&#8217;s an example:</p>
<p>In one session I&#8217;m running a DBMS_STATS call:</p>
<pre class="brush: plain; title: ; notranslate">SQL&gt; exec dbms_stats.gather_database_stats;
</pre>
<p>I identify the SPID of that session&#8217;s process and send an URG signal to that process:</p>
<pre class="brush: plain; title: ; notranslate">kill -URG 4476
</pre>
<p>And the call gets cancelled in the other session:</p>
<pre class="brush: plain; title: ; notranslate">SQL&gt; exec dbms_stats.gather_database_stats;
&lt;pre&gt;BEGIN dbms_stats.gather_database_stats; END;

*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01013: user requested cancel of current operation
ORA-06512: at &quot;SYS.DBMS_STATS&quot;, line 13336
ORA-06512: at &quot;SYS.DBMS_STATS&quot;, line 13682
ORA-06512: at &quot;SYS.DBMS_STATS&quot;, line 13826
ORA-06512: at &quot;SYS.DBMS_STATS&quot;, line 13790
ORA-06512: at line 1
</pre>
<p>My session was not killed &#8211; I still can run queries in it:</p>
<pre class="brush: plain; title: ; notranslate">SQL&gt; select * from dual;

D
-
X

SQL&gt;
</pre>
<p>This works only on Unix platforms. Also this does <span style="text-decoration: underline;">not</span> work when your client application is Windows sqlplus! This is because Windows sqlplus does not set up the out-of-band break checking properly when connecting. Maybe this is because old Windows versions TCP stacks didn&#8217;t know anything about urgent TCP packets! :)</p>
<p>A word of warning &#8211; this stuff is not for your everyday production usage! While it works and we know <em>how and why</em> it works, it&#8217;s not a good idea to send &#8220;random&#8221; signals to Oracle processes at your will. So the better way is to make your application able to cancel its database calls when you want it, but well in real world its not always (or should I even say rarely) possible.</p>
<p>Another thing to consider is when you run Oracle with Direct NFS, there will be network connections to the NFS server used by your server process, in addition to the client-server communication. I haven&#8217;t tested what happens when you send URG packet to a process in the DNFS case.</p>
<p>So try this out at your own risk ;-)</p>
<p>If you want to know more about query cancelling and what the in-band and out-of-band break checking is then you can read one of my old blog posts about it:</p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOC8wMi8wNS9vcmFjbGUtaGlkZGVuLWNvc3RzLXJldmVhbGVkLXBhcnQtMS8=">http://blog.tanelpoder.com/2008/02/05/oracle-hidden-costs-revealed-part-1/</a></li>
</ul>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=628" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/02/17/how-to-cancel-a-query-running-in-another-session/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Using Process Memory Matrix script for calculating Oracle process memory usage on Solaris</title>
		<link>http://blog.tanelpoder.com/2010/02/11/using-process-memory-matrix-script-for-calculating-oracle-process-memory-usage-on-solaris/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-process-memory-matrix-script-for-calculating-oracle-process-memory-usage-on-solaris</link>
		<comments>http://blog.tanelpoder.com/2010/02/11/using-process-memory-matrix-script-for-calculating-oracle-process-memory-usage-on-solaris/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 18:21:04 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=604</guid>
		<description><![CDATA[I just published a new script and article about calculating the real Oracle process memory usage on Solaris. The problem with V$PROCESS* views (and the V$SESSTAT) is that they will tell you what Oracle thinks it&#8217;s using, not the real amount of memory used. There will be discrepancies due how memory is actually allocated in [...]]]></description>
			<content:encoded><![CDATA[<p>I just published a new script and article about calculating the <em>real</em> Oracle process memory usage on Solaris.</p>
<p>The problem with V$PROCESS* views (and the V$SESSTAT) is that they will tell you what Oracle <em>thinks</em> it&#8217;s using, not the real amount of memory used. There will be discrepancies due how memory is actually allocated in OS, libraries out of Oracle&#8217;s control, the static memory areas inside Oracle binary and of course bugs.</p>
<p>I was working on one of such problems and decided to make my life easier by writing the script. It&#8217;s not so much about calculating the exact figures (they will never be 100% correct), but more about presenting the memory usage data in a better and more convenient fashion.</p>
<p>The script is called <strong>procmm </strong>and stands for Process Memory Matrix as it shows the memory usage in a matrix grid.</p>
<p>Here&#8217;s an example output to show what I&#8217;m talking about:</p>
<pre class="brush: plain; title: ; notranslate">
oracle@solaris02:~/research/memory$ ./procmm.sh -t `pgrep -f ora_.*SOL102`

-- procmm.sh: Process Memory Matrix v1.01 by Tanel Poder ( http://tech.e2sn.com )
-- All numbers are shown in kilobytes

Total PIDs 17, working: .................

PID            SEGMENT_TYPE      VIRTUAL          RSS         ANON       LOCKED    SWAP_RSVD
------ -------------------- ------------ ------------ ------------ ------------ ------------
0                       lib       389844       388796        13180            0        17816
0                    oracle      1629064      1628908         3336            0        42012
0            ism_shmid=0x1d      6963336      6963336            0      6963336            0
0             hc_SOL102.dat           48           48            0            0            0
0                      anon        32936        15936        15452            0        32868
0                     stack         1660         1628         1592            0         1660
0                      heap        37004        18016        16844            0        37004
------ -------------------- ------------ ------------ ------------ ------------ ------------
0                 TOTAL(kB)      9053892      9016668        50404      6963336       131360
</pre>
<p>And here&#8217;s the full article and in there a link to the script:</p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlL3BlcmZvcm1hbmNlL3VuaXgtcGVyZm9ybWFuY2UtdG9vbHMvcHJvY2Vzcy1tZW1veS1tYXRyaXg=" target=\"_blank\"></a><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlL3BlcmZvcm1hbmNlL3VuaXgtcGVyZm9ybWFuY2UtdG9vbHMvcHJvY2Vzcy1tZW1vcnktbWF0cml4" target=\"_blank\">http://tech.e2sn.com/oracle/performance/unix-performance-tools/process-memory-matrix</a></li>
</ul>
<p>Comments are welcome here, as I haven&#8217;t set up commenting on my other site yet&#8230;</p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=604" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/02/11/using-process-memory-matrix-script-for-calculating-oracle-process-memory-usage-on-solaris/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>I&#8217;m tweeting now&#8230;</title>
		<link>http://blog.tanelpoder.com/2009/10/18/im-tweeting-now/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=im-tweeting-now</link>
		<comments>http://blog.tanelpoder.com/2009/10/18/im-tweeting-now/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 18:34:07 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/2009/10/18/im-tweeting-now/</guid>
		<description><![CDATA[Although I don&#8217;t think I have much useful to say in 160 characters, but we&#8217;ll see You can follow me here: http://twitter.com/tanelpoder Or just check out the right hand twitter widget in my blog&#8230;]]></description>
			<content:encoded><![CDATA[<p>Although I don&#8217;t think I have much useful to say in 160 characters, but we&#8217;ll see</p>
<p>You can follow me here:</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3R3aXR0ZXIuY29tL3RhbmVscG9kZXI=">http://twitter.com/tanelpoder</a></p>
<p>Or just check out the right hand twitter widget in my blog&#8230;</p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=466" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/10/18/im-tweeting-now/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oracle Performance Visualization videos from Sydney</title>
		<link>http://blog.tanelpoder.com/2009/05/27/oracle-performance-visualization-videos-from-sydney/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=oracle-performance-visualization-videos-from-sydney</link>
		<comments>http://blog.tanelpoder.com/2009/05/27/oracle-performance-visualization-videos-from-sydney/#comments</comments>
		<pubDate>Wed, 27 May 2009 13:18:31 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=320</guid>
		<description><![CDATA[Alex Gorbachev invited me to speak at Oracle Meetup @ Sydney event in April. I in addition to useful (and less cool) stuff I showed some useful (and very cool) stuff there too. I demoed my PerfSheet tool and also something completely new what I&#8217;ve been working on for last few months. Alex has uploaded [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5weXRoaWFuLmNvbS9uZXdzL2F1dGhvci9hbGV4">Alex Gorbachev</a> invited me to speak at Oracle Meetup @ Sydney event in April.</p>
<p>I in addition to useful (and less cool) stuff I showed some useful (and very cool) stuff there too. I demoed my PerfSheet tool and also something completely new what I&#8217;ve been working on for last few months. Alex has uploaded couple of videos in to youtube, if you&#8217;re interested what I&#8217;ve been up to in last few months, check them out here:</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5weXRoaWFuLmNvbS9uZXdzLzI1OTAvc3lkbmV5LW9yYWNsZS1tZWV0dXAtMi12aXN1YWxpemluZy1vcmFjbGUtcGVyZm9ybWFuY2U=" target=\"_blank\">http://www.pythian.com/news/2590/sydney-oracle-meetup-2-visualizing-oracle-performance</a></p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=320" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/05/27/oracle-performance-visualization-videos-from-sydney/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Performance Visualization made easy &#8211; PerfSheet 2.0 beta</title>
		<link>http://blog.tanelpoder.com/2008/12/28/performance-visualization-made-easy-perfsheet-20-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=performance-visualization-made-easy-perfsheet-20-beta</link>
		<comments>http://blog.tanelpoder.com/2008/12/28/performance-visualization-made-easy-perfsheet-20-beta/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 15:19:36 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=168</guid>
		<description><![CDATA[Hi all, I have been extremely busy over last couple of months, that&#8217;s why there haven&#8217;t been any blog entries (no, I haven&#8217;t ran out of good ideas ;-) I just managed to find some time on a day-time 9-hour flight from Shanghai to Finland, thus here&#8217;s a blog entry about something what I had [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>I have been extremely busy over last couple of months, that&#8217;s why there haven&#8217;t been any blog entries (no, I haven&#8217;t ran out of good ideas ;-)<br />
I just managed to find some time on a day-time 9-hour flight from Shanghai to Finland, thus here&#8217;s a blog entry about something what I had wanted to write about for long time&#8230; I&#8217;m talking about the PerfSheet tool I wrote a year ago and have been showing at few conferences already. It has been a great time saver for me over this year when working through performance data for troubleshooting or capacity planning tasks.</p>
<p>If you don&#8217;t want to read further through my comments, just download PerfSheet from <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9QZXJmU2hlZXQuemlw">http://www.tanelpoder.com/files/PerfSheet.zip</a> and see how it works yourself!</p>
<p>For others, let me give some history first:</p>
<p><span id="more-168"></span></p>
<ol>
<li>A client had some serious performance problems after an HBA driver upgrade on a weekend.</li>
<li>DBAs were blamed first and they started looking into Statspack reports (as that was the only performance history data they had).</li>
<li>Current Statspack reports didn&#8217;t show anything too extraordinary (as everybody knew this database was running quite non-optimally anyway).</li>
<li>By that time, both storage and Unix admins &#8220;had done the healthchecks and everything looked fine&#8221;</li>
<li>But something was definitely different today as the end user response times were much worse.</li>
<li>(This is a case where we didn&#8217;t care about general inefficiency of the application as this is what the application had been like all the time. Instead of systematically starting optimizing the database we just had to find what had gone wrong over the weekend and fix it. In other words, something had got <em>F-ed</em> up over the weekend and we needed to <em>un-F</em> it ;).</li>
<li>Thus the troubleshooters (including me) started comparing the &#8220;current&#8221; statspack reports with previous ones to see what were the main differences in wait and load profiles were.</li>
<li>But it wasn&#8217;t as easy as just taking last days snapshot from the same time as the load &amp; wait profile of that system was fluctuating anyway as some heavily parallel batch jobs started and finished (at different times).</li>
<li>Based on the statspack numbers the DBAs suspected that there was something wrong with IO configuration (especially as there had been a HBA driver upgrade over the weekend)</li>
<li>Taking tens of 50-page statspack reports to a fingerpointing meeting with SAs, storage admins, high level directors etc didn&#8217;t work well&#8230;</li>
</ol>
<p>Then I thought to visualize the numbers in Excel to get our point (and proof) through better.</p>
<p>Running Statspack reports manually and pasting numbers from there into Excel <em>very</em> boring, slow and error prone task. I actually started doing this but after 10 (painful) minutes I thought, heck, why am I doing all this manually?</p>
<p>This is how PerfSheet was born. I wrote the first version in couple of hours and it just ran an analytic query (downloaded the query from <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5ldmRidC5jb20vdG9vbHMuaHRt">Tim Gorman&#8217;s site</a>) against statspack repository. After fetching the SQL resultset to Excel, the sheet also automatically displayed the results in a graph (so we could refresh the graph after querying different stats out of statspack repository).</p>
<p><img src="http://www.tanelpoder.com/files/images/io_before_after.png" border="0" alt="" /></p>
<p>And armed with the wait profile graph above we were able to show hard evidence in a simple package (as opposed to tens of statspack reports) at the next meeting with storage and Unix teams. It&#8217;s very hard to argue with evidence like that, especially if managers are involved :) It&#8217;s much easier to discard a DBA with 500 pages of statspack reports blabbering about Oracle wait interface than someone who shows a visual overview of database health.</p>
<p>This led the Unix SAs to do another healthcheck and this time they found out that one of the two HBAs had been left deactivated after the driver upgrade. After the HBA was activated (online), the performance went back to normal.</p>
<p>So, sometimes, especially if multiple teams are involved in troubleshooting a sudden peformance problem (and there&#8217;s negative fingerpointing and protectionism going on), it&#8217;s hard to beat historical performance visualization. Instead of going through tens of pages of raw numbers you can just visualize that data and see if your eye catches a sudden change, trend or outlier.</p>
<p>And this leads me to version 2.0 (beta) of PerfSheet.</p>
<p>It allows you to do ad-hoc visualization of any SQL resultset. Excel runs your specified SQL statement, fetches data onto a worksheet and shows the results on a PivotChart. I have actually written only few lines of code to glue Excel&#8217;s SQL execution, data fetching and visualization modules together for convenience, Excel itself does most of the work.</p>
<p>When you open up the <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9QZXJmU2hlZXQuemlw">PerfSheet.xls</a>, just fill in the connect details on the first page and click &#8220;Show me&#8221; and see what I mean (note that some queries do query v$active_session_history and DBA_HIST tables so make sure you have the proper licenses for querying these views).</p>
<p>Once the graph is displayed you can even drag and drop the data fields around into different axis to get a different breakdown of the statistics. Try it out and you&#8217;ll love it :)<br />
Also, you can hover your mouse over some data element to get its description, as I&#8217;ve done here to see a SQLID matching an ASH sample on an ASH query:</p>
<p><img src="http://www.tanelpoder.com/files/images/3d_ash.png" border="0" alt="" /></p>
<p>As a next step, just navigate around at the Queries, Views and Help tabs and read the comments at column headers on how to define your own queries and visualization views. And if it doesn&#8217;t work, let me know.</p>
<p>Also, one more important thing. I used Excel for data fetching and visualization and I uset it on purpose. I haven&#8217;t seen a corporation yet where there is no Windows workstation and Excel available. Often I hear people saying that I should just use some Perl/Python/TCL/Java module or toolkit suth RRD etc as then you can put your graphs into web and &#8220;everybody has a web browser&#8221;.</p>
<p>I say that the mentioned technologies are for entirely different purpose. Yes, everybody does have a web browser, but In a corporation it&#8217;s not easy at all to get a (virtual) webserver for your purpose (and get all the software downloaded, configured and installed). When you have a serious production problem to troubleshoot, you don&#8217;t want to start installing and configuring webservers :)</p>
<p>The webserver approach is good for proactive, predetermined visualization, e.g. you know what you want to monitor and you make that data available in the intranet. But PerfSheet is <em>perfect</em> (thus the name :) for ad-hoc performance visualization of any SQL resultset on pretty much any corporate workstation.</p>
<p>So, Merry Christmas and happy visualization in the next year ;)</p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=168" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2008/12/28/performance-visualization-made-easy-perfsheet-20-beta/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>Austrian Oracle User Group event on 15th Oct in Vienna</title>
		<link>http://blog.tanelpoder.com/2008/10/14/austrian-oracle-user-group-event-on-15th-oct-in-vienna/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=austrian-oracle-user-group-event-on-15th-oct-in-vienna</link>
		<comments>http://blog.tanelpoder.com/2008/10/14/austrian-oracle-user-group-event-on-15th-oct-in-vienna/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 16:54:29 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tanelpoder.wordpress.com/?p=143</guid>
		<description><![CDATA[I will be speaking at Austrian Oracle User Group event in Vienna this Wednesday (15. Oct) with Christian Antognini I will deliver an 1 hour version of my Advanced Oracle Troubleshooting presentation there, so if you&#8217;re in Austria and want to see what&#8217;s coming in my full length seminar I deliver on 3.-4. Nov also [...]]]></description>
			<content:encoded><![CDATA[<p>I will be speaking at <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2FvdWcuYXQvMjAwOC9leHBfMDgxMDE1Lmh0bQ==">Austrian Oracle User Group event in Vienna</a> this Wednesday (15. Oct) with <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2FudG9nbmluaS5jaA==">Christian Antognini</a></p>
<p>I will deliver an 1 hour version of my Advanced Oracle Troubleshooting presentation there, so if you&#8217;re in Austria and want to see what&#8217;s coming in my full length seminar I deliver on 3.-4. Nov also in Vienna, then you can see a preview on this Wednesday :)</p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=143" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2008/10/14/austrian-oracle-user-group-event-on-15th-oct-in-vienna/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Debugger dangers</title>
		<link>http://blog.tanelpoder.com/2008/06/14/debugger-dangers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugger-dangers</link>
		<comments>http://blog.tanelpoder.com/2008/06/14/debugger-dangers/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 11:51:54 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tanelpoder.wordpress.com/2008/06/14/debugger-dangers/</guid>
		<description><![CDATA[Whenever I deliver training or conference presentations on advanced troubleshooting topics, I usually spend some time demonstrating how to get and interpret Oracle server process stack traces. As I&#8217;ve mentioned before, stack traces are the ultimate indicators showing where in Oracle kernel (or whatever application) code the execution currently is (or where it was when [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I deliver training or conference presentations on advanced troubleshooting topics, I usually spend some time demonstrating how to get and interpret Oracle server process stack traces.<br />
As I&#8217;ve mentioned before, stack traces are the ultimate indicators showing where in Oracle kernel (or whatever application) code the execution currently is (or where it was when a crash occurred). This is the reason Oracle Support asks for stack traces whenever there&#8217;s a crash or non-trivial hang involved, that&#8217;s why Oracle database dumps errorstacks when ORA-600&#8242;s and other exceptions occur.</p>
<p>There are multiple ways for getting stack traces for Oracle, but not all ways are equal. Some give you more contextual info, some less, but what I&#8217;m blogging about today is that some ways are less safe than others.</p>
<p>I was using <strong>pstack</strong> on Linux for diagnosing an IO related performance issue. I executed a <em>create table as select</em> statement and ran pstack in a loop for getting stack traces from the running process.</p>
<p>However in one of the test runs I got following error in my Oracle session:</p>
<pre><code>SQL&gt; create table t as select * from dba_source;
create table t as select * from dba_source
                                *
ERROR at line 1:
ORA-01115: IO error reading block from file 1 (block # 11161)
ORA-01110: data file 1: '/u01/oradata/LIN10G/system01.dbf'
<strong>ORA-27091: unable to queue I/O
ORA-27072: File I/O error
</strong>Additional information: 3
Additional information: 11145
Additional information: 32768

</code></pre>
<p>I suspected that this issue was due Linux pstack, stopped the pstack script and ran my CTAS from <em>the same Oracle session</em> again:</p>
<p><span id="more-80"></span></p>
<pre><code>SQL&gt; create table t as select * from dba_source;

Table created.

</code></pre>
<p>The command now succeeded ok.</p>
<p>I tried to reproduce the failure again, but during the few minutes I spent testing, it didn&#8217;t occur again.</p>
<p>The failure happened likely due the fact that pstack on Linux is actually just a wrapper script around gdb. GDB in turn suspends the process under investigation and attaches to it through ptrace() syscall. And ptrace() syscall (and debuggers in general) have historically caused issues to host processes when communicating with kernel and other processes. For example they can block some signals or interrupts from being propagated back up to the &#8220;host&#8221; process.</p>
<p>Normally I have warned people about using debugger-based stack tracing due exactly those reasons, and now I managed to capture nice evidence.<br />
I recommend to stay away with debugger from critical background processes on production systems, unless things have already collapsed anyway (that ought to be common sense anyway). So it&#8217;s good to know that Linux pstack is actually just a script with GDB backtrace command in it.</p>
<p>So, what are the safer and less safer stack tracing options:</p>
<ul>
<li>oradebug dump errorstack &#8211; unsafe for production (as dump errorstack actually alters the process under investigation from its original codepath)</li>
<li>debugger based errorstack (gdb,dbx,mdb and Linux pstack) &#8211; can be unsafe for production due missed signals &amp; interrupts if you get unlucky. Therefore you should stay away from at least the critical background processes with such tools</li>
<li>pstack on Solaris (and procstack on AIX) &#8211; safe as they don&#8217;t use the ptrace() interface but just read the info required from /proc filesystem</li>
<li>DTrace &#8211; safe by design</li>
</ul>
<p>I haven&#8217;t checked how HP-UX pstack works, so can&#8217;t advise on that.</p>
 <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=80" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2008/06/14/debugger-dangers/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

