<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Erik Wramner</title>
	<atom:link href="http://erikwramner.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://erikwramner.wordpress.com</link>
	<description>Tips and tricks</description>
	<lastBuildDate>Sat, 28 Jan 2012 08:51:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='erikwramner.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/a7b4ba240529f5a8b9fd6d242b33dac8?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Erik Wramner</title>
		<link>http://erikwramner.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://erikwramner.wordpress.com/osd.xml" title="Erik Wramner" />
	<atom:link rel='hub' href='http://erikwramner.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Global transactions with JMS or AQ and BPEL in 11g</title>
		<link>http://erikwramner.wordpress.com/2011/11/07/global-transactions-with-jms-or-aq-and-bpel-in-11g/</link>
		<comments>http://erikwramner.wordpress.com/2011/11/07/global-transactions-with-jms-or-aq-and-bpel-in-11g/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 09:52:03 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[SOA Suite]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=139</guid>
		<description><![CDATA[The concept of a global (XA) transaction is very useful in many integration scenarios, as it is much easier to operate a solution where all changes or no changes are performed. BPEL is primarily intended for long-running processes where a single global transaction is impractical, but even so it is often possible to model using [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=139&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The concept of a global (XA) transaction is very useful in many integration scenarios, as it is much easier to operate a solution where all changes or no changes are performed. BPEL is primarily intended for long-running processes where a single global transaction is impractical, but even so it is often possible to model using transactional parts with known milestones. This pattern is used in <a href="http://download.oracle.com/docs/cd/E21764_01/doc.1111/e17364/designpatterns.htm#BCEJBABB">Oracle AIA</a>, for example. In the real world many organizations use BPEL for simple processes where a single global transaction can be used as well.</p>
<p>Assume that a message arrives on a queue. It needs to be transformed and processed somehow; then another message should be written to an output queue, a database should be updated and a long-running asynchronous process spawned. If something goes wrong the message should be rolled back to the input queue where it can be retried (or eventually moved to dead letters by the queue manager) and all the other changes should be rolled back as well.</p>
<p>This was possible to do in 10.1.3.3, but it required some black magic. The WSDL file for the input adapter had to be modified and all the BPEL processes had to run in-memory with completionPersistLevel=off and with transaction=participate everywhere. It worked, but the instances would never appear in the BPEL console, making it hard to see what was going on in the system.</p>
<p>With 11g this works much better. It is no longer necessary to use in-memory optmization and the full audit trail can be saved and viewed in the console. The Mediator can be used as well. However, the procedure is still poorly documented and it still requires manual changes in the generated code.</p>
<p>To try it out, create two queues (one inbound and one outbound) and a test table. Create a new composite. Add an inbound AQ or JMS adapter and an outbound AQ or JMS adapter. Add a database adapter for the test table. Create an asynchronous BPEL process that does nothing. Create a synchronous BPEL process that inserts a record into the table, calls the asynhrounous BPEL process and finally enqueues a message into the output queue. Finally create another BPEL process or Mediator component that dequeues a message from the input queue and invokes the synchronous BPEL process.</p>
<p>Enqueue a message on the input queue. The entire flow should appear in the console, a new record should be present in the table and a message should appear in the output queue. So far so good. Now, disable enqueue for the output queue and try again. What happens? Without a global transaction the message will be removed from the input queue, a new record will appear in the table, the asynchronous process will run but nothing appears on the output queue!</p>
<p>Right, do the obvious thing. Edit composite.xml and add bpel.config.transaction=required for all the BPEL processes. Assuming that the application server has been configured correctly with an XA data source this should do the trick, right? Wrong. The changes are rolled back, so there will be no new record in the table and no asynchronous process. However, the message is still removed from the input queue and lost.</p>
<p>Time for some undocumented magic. Edit the WSDL file for the input adapter and add a new type, a new element and a new message. Include the new message as output message, making the WSDL synchronous. For example (assuming an opaque JMS adapter and showing only the relevant parts):</p>
<p><a href="http://erikwramner.files.wordpress.com/2011/11/jms_xa_wsdl_example.png"><img class="alignnone size-medium wp-image-141" title="jms_xa_wsdl_example" src="http://erikwramner.files.wordpress.com/2011/11/jms_xa_wsdl_example.png?w=300&#038;h=167" alt="" width="300" height="167" /></a></p>
<p>Edit the BPEL process or Mediator component that dequeues the message and add a reply to the adapter. Good to go? Almost. Everything looks good, but for some reason the message will still be lost. As a final step the input adapter must be configured with jca.retry.all=true in composite.xml. With that option in place, deploy the code and try again. This time the message should be returned to the input queue and retried and eventually moved to dead letters, where it can be handled.</p>
<p>In summary:</p>
<p>1) Configure all BPEL processes with bpel.config.transaction=required in composite.xml.<br />
2) Modify the generated WSDL file for the AQ or JMS adapter and add an output message, making it synchronous.<br />
3) Configure the AQ or JMS adapter with jca.retry.all=true in composite.xml.<br />
4) Use an XA data source.</p>
<p>This has been tested with 11.1.1.5.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=139&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2011/11/07/global-transactions-with-jms-or-aq-and-bpel-in-11g/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>

		<media:content url="http://erikwramner.files.wordpress.com/2011/11/jms_xa_wsdl_example.png?w=300" medium="image">
			<media:title type="html">jms_xa_wsdl_example</media:title>
		</media:content>
	</item>
		<item>
		<title>SSL issues with jDeveloper</title>
		<link>http://erikwramner.wordpress.com/2011/10/31/ssl-issues-with-jdeveloper/</link>
		<comments>http://erikwramner.wordpress.com/2011/10/31/ssl-issues-with-jdeveloper/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 10:30:50 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[SOA Suite]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=135</guid>
		<description><![CDATA[How to solve SSL issues with self-signed certificates in jDeveloper.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=135&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In test environments it is common to use self-signed SSL certificates. In addition to being self-signed they tend to be less strict, for instance the CN may not match the host name. This will cause problems if jDeveloper 11.1.1.5 needs to read WSDL using SSL, for example.</p>
<p>The compiler will fail with a message similar to &#8220;Load of wsdl &#8230; failed&#8221;. The SOA log (scac.log) may contain:<br />
<code><br />
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target<br />
</code><br />
In this case the self-signed certificate must be added to the keystore for the JRE used by jDeveloper. Access the server with a browser and open the certificate. Export it as a file. DER format works. Close jDeveloper. Import the certificate:<br />
<code><br />
set JAVA_HOME=c:\oracle\Middleware\jdk160_24<br />
set PATH=%JAVA_HOME%\bin;%PATH%<br />
keytool -import -trustcacerts -file certificate.der -keystore %JAVA_HOME%\jre\lib\security\cacerts<br />
</code><br />
The default password is &#8220;changeit&#8221;. Start jDeveloper and try again. This time the certificate should be accepted, but there may still be problems. The SOA log (scac.log) may contain:<br />
<code><br />
java.security.cert.CertificateException: No name matching hostname.domain.name found<br />
</code><br />
In this case the SSL certificate uses the wrong CN. There are no options for ignoring hostname verification in JDeveloper (<a href="http://download.oracle.com/docs/cd/E12839_01/integration.1111/e10224/sca_lifecycle.htm">docs</a>), so the names must match. Fix the certificate, there is no workaround.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=135&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2011/10/31/ssl-issues-with-jdeveloper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>
	</item>
		<item>
		<title>Symbolic links and CIFS/SMB with FreeNAS 0.7.2</title>
		<link>http://erikwramner.wordpress.com/2011/08/14/symbolic-links-and-cifssmb-with-freenas-0-7-2/</link>
		<comments>http://erikwramner.wordpress.com/2011/08/14/symbolic-links-and-cifssmb-with-freenas-0-7-2/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 13:53:34 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[FreeNAS]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=131</guid>
		<description><![CDATA[Symbolic links across zfs file systems stopped working with Windows file sharing after a FreeNAS upgrade. Fix the problem with three auxiliary parameters.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=131&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded to FreeNAS 0.7.2 revision 6694 and suddenly symbolic links across zfs filesystems stopped working when accessed using Windows file sharing (CIFS/SMB). They still worked fine from the command line. Apparently the root cause is a security fix in Samba. To work around the change, add the following to &#8220;Auxiliary parameters&#8221; for CIFS/SMB in the FreeNAS web ui:</p>
<p><code>follow symlinks=yes<br />
wide links=yes<br />
unix extensions=off</code></p>
<p>They will then be added to the global section of smb.conf. Select &#8220;Save and Restart&#8221; and the links should work again.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=131&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2011/08/14/symbolic-links-and-cifssmb-with-freenas-0-7-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>
	</item>
		<item>
		<title>Subversion on FreeNAS</title>
		<link>http://erikwramner.wordpress.com/2010/12/14/subversion-on-freenas/</link>
		<comments>http://erikwramner.wordpress.com/2010/12/14/subversion-on-freenas/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 12:16:10 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[FreeNAS]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=123</guid>
		<description><![CDATA[How to install a Subversion server on FreeNAS embedded.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=123&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Like several other FreeNAS users I would like to run a Subversion server on my FreeNAS box. Sure, it is discouraged, but the alternative for me is to use an Internet-facing server or to keep a third machine running all the time. The FreeNAS box seems like the best choice.</p>
<p>The installation process is a bit involved as the embedded version of FreeNAS keeps the root file system in RAM. A standard installation will simply disappear after the first reboot.</p>
<p>Create a group and a user named svn through the web interface. Note that if you want to su to svn later on, a real shell is required, nologin will not work. Login to the Unix prompt and su to root. Create a directory on one of the mounted disks (not the root file system, which is a RAM disk!):</p>
<pre><code>
mkdir -p /mnt/data/apps/Subversion
</code></pre>
<p>Install the subversion package to the proper location:</p>
<pre><code>
setenv PKG_TMPDIR /mnt/data/apps/Subversion
pkg_add -r subversion -P /mnt/data/apps/Subversion
</code></pre>
<p>Include the dynamic libraries in the search path:</p>
<pre><code>
ldconfig -Rm /mnt/data/apps/Subversion/lib
</code></pre>
<p>Create a repository. Again the location must be on a mounted disk:</p>
<pre><code>
/mnt/data/apps/Subversion/bin/svnadmin create /mnt/data/apps/Subversion/svnrep
</code></pre>
<p>Configure the repository.</p>
<pre><code>
vi /mnt/data/apps/Subversion/svnrep/conf/svnserve.conf
</code></pre>
<p>Apart from comments this is an example:</p>
<pre><code>
[general]
anon-access = none
auth-access = write
password-db = passwd
realm = FreeNAS
</code></pre>
<p>Edit the password file (<code>vi /mnt/data/apps/Subversion/svnrep/conf/passwd</code>) and add users:</p>
<pre><code>
[users]
userid1 = password1
userid2 = password2
</code></pre>
<p>Create a start script for the Subversion daemon:</p>
<pre><code>
vi /mnt/data/apps/Subversion/bin/start_svnserve.sh
</code></pre>
<p>The start script needs to include the Subversion libraries before it launches svnserve:</p>
<pre><code>
#!/bin/bash
ldconfig -Rm /mnt/data/apps/Subversion/lib
su svn -c '/mnt/data/apps/Subversion/bin/svnserve -d
  --listen-host=n.n.n.n -r /mnt/data/apps/Subversion/svnrep'
</code></pre>
<p>The svnserve command should use a single line, wrapped for readability. Without the listen-host option Subversion may use an IPv6 address. Use the option with your IPv4 address to get around that. Make the script executable:</p>
<pre><code>
chmod +x /mnt/data/apps/Subversion/bin/start_svnserve.sh
</code></pre>
<p>Change ownership of all files properly:</p>
<pre><code>
cd /mnt/data/apps/Subversion
chown -R svn:svn svnrep
</code></pre>
<p>Test the script. If it works, add it as a PostInit start script (System/Advanced/Command scripts). Voila, FreeNAS is running Subversion!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=123&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2010/12/14/subversion-on-freenas/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>
	</item>
		<item>
		<title>Interval partitioning with automated cleanup</title>
		<link>http://erikwramner.wordpress.com/2010/10/28/interval-partitioning-automated-cleanup/</link>
		<comments>http://erikwramner.wordpress.com/2010/10/28/interval-partitioning-automated-cleanup/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 17:39:42 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=119</guid>
		<description><![CDATA[How to use the interval partitioning scheme and extract high_value dates for automated cleanup.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=119&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For large databases partitioning is not only great, it is necessary. Unfortunately it adds new problems. One such problem is how to create new partitions so that they are available when they are needed. It often requires the use of an overflow partition, moving data to the real partitions when they come online. It also tends to require priviliges not granted to developers.</p>
<p>With Oracle 11g this becomes much easier. With the new interval partitioning scheme the database automatically creates new partitions when they are needed. A template partition is created from the start; the system takes care of the rest.</p>
<p>For example, to create a new partition for each day:</p>
<pre><code>create table test_tab (
  created_date   date default sysdate
 ,partition_key  date generated always as (trunc(created_date)) virtual
 ,test_col_1     number
) partition by range (partition_key)
    interval (NUMTODSINTERVAL(1,'DAY')) (
    partition test_tab_initial_part
      values less than (to_date('20100121', 'YYYYMMDD')
  )
);
</code></pre>
<p>Note that a virtual column is used for the partitioning key; another 11g feature. Try it out:</p>
<pre><code>
insert into test_tab (test_col_1) values (1);
commit;
select partition_name, high_value
  from user_tab_partitions where table_name = 'TEST_TAB';

PARTITION_NAME        HIGH_VALUE
--------------------- ----------------------------
TEST_TAB_INITIAL_PART TO_DATE(' 2010-01-21 ...
SYS_P42               TO_DATE(' 2010-10-29 ...
</code></pre>
<p>A new partition has been created on the fly.</p>
<p>While this is great it solves only half the problem. The old partitions must be dropped eventually. How can we automate that?</p>
<p>First we need to find the partitions that can be dropped. This is a bit tricky as the high_value column in user_tab_partitions is a LONG that contains a SQL expression rather than a value we can use in comparisons. Our first task is to write a function that converts a high_value to a date:</p>
<pre><code>
create or replace function get_high_value_as_date(
  p_table_name     in varchar2,
  p_partition_name in varchar2
) return date as
  v_high_value varchar2(1024);
  v_date        date;
begin
  select high_value into v_high_value from user_tab_partitions
    where table_name = upper(p_table_name)
      and partition_name = upper(p_partition_name);
  execute immediate 'select ' || v_high_value || ' from dual' into v_date;
  return v_date;
end;
</code></pre>
<p>Armed with the conversion function we can loop over the partitions for our table and drop the obsolete ones:</p>
<pre><code>
declare
  c_days_to_keep constant integer := 31;
  x_last_partition exception;
  pragma exception_init(x_last_partition, -14758);
begin
  for rec in (select table_name, partition_name
    from user_tab_partitions
      where table_name = 'TEST_TAB'
        and get_high_value_as_date(table_name, partition_name) &lt;
        sysdate - c_days_to_keep) loop
    begin
      execute immediate &#039;alter table &#039; || rec.table_name ||
        &#039; drop partition &#039; || rec.partition_name;
    exception
      when x_last_partition then
        null;
    end;
  end loop;
end;
</code></pre>
<p>Note that we cannot drop the template partition.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/119/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=119&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2010/10/28/interval-partitioning-automated-cleanup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>
	</item>
		<item>
		<title>Map the Oracle ESB repository as a drive with Windows XP</title>
		<link>http://erikwramner.wordpress.com/2010/10/25/esb-as-windows-drive/</link>
		<comments>http://erikwramner.wordpress.com/2010/10/25/esb-as-windows-drive/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 17:11:10 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[SOA Suite]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=112</guid>
		<description><![CDATA[How to map the Oracle ESB repository as a WebDAV network drive with Windows XP.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=112&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The ESB in Oracle SOA Suite publishes its resources as a WebDAV repository. That means that it can be mapped as a Windows drive or mounted in Linux. This can be very useful as the ESB (intentionally) keeps all files when a service is deleted. They must be removed manually. With a network drive that becomes child’s play.</p>
<p>It should be possible to define a network drive as follows:</p>
<p><code>net use x: "http://192.168.157.23:7777/esb/slide"</code></p>
<p>That fails with:</p>
<p><code>System error 67 has occurred.</code></p>
<p>The same thing happens from the user interface in Windows Explorer. Fortunately there is a solution – add a network place instead. Select “Tools/Map Network Drive”. Click on the link “Sign up for online storage or connect to a network server”:</p>
<p><a href="http://erikwramner.files.wordpress.com/2010/10/step1.gif"><img src="http://erikwramner.files.wordpress.com/2010/10/step1.gif?w=600" alt="" title="Map network drive"   class="alignnone size-full wp-image-113" /></a></p>
<p>Click next until prompted for the address. Enter the host and port for the ESB server followed by “/esb/slide”:</p>
<p><a href="http://erikwramner.files.wordpress.com/2010/10/step2.gif"><img src="http://erikwramner.files.wordpress.com/2010/10/step2.gif?w=600" alt="" title="Enter address"   class="alignnone size-full wp-image-114" /></a></p>
<p>Give the new network place a name. This will become the name of a folder where the repository can be found:</p>
<p><a href="http://erikwramner.files.wordpress.com/2010/10/step3.gif"><img src="http://erikwramner.files.wordpress.com/2010/10/step3.gif?w=600" alt="" title="Enter name"   class="alignnone size-full wp-image-115" /></a></p>
<p>Finish the wizard. There will be a new folder present in “My Network Places”. It can be copied or moved somewhere else just like a normal folder. Expand it and voila – there are the ESB files.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=112&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2010/10/25/esb-as-windows-drive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>

		<media:content url="http://erikwramner.files.wordpress.com/2010/10/step1.gif" medium="image">
			<media:title type="html">Map network drive</media:title>
		</media:content>

		<media:content url="http://erikwramner.files.wordpress.com/2010/10/step2.gif" medium="image">
			<media:title type="html">Enter address</media:title>
		</media:content>

		<media:content url="http://erikwramner.files.wordpress.com/2010/10/step3.gif" medium="image">
			<media:title type="html">Enter name</media:title>
		</media:content>
	</item>
		<item>
		<title>Pitfall with active-passive oc4j</title>
		<link>http://erikwramner.wordpress.com/2010/10/25/pitfall-active-passive-oc4j/</link>
		<comments>http://erikwramner.wordpress.com/2010/10/25/pitfall-active-passive-oc4j/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 05:30:41 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[SOA Suite]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=107</guid>
		<description><![CDATA[How to prevent opmn from starting both nodes in an active-passive configuration.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=107&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We recently had some issues with SOA Suite 10.1.3.3 using an active-passive oc4j configured in the usual way with service-failover and service-weight added and numprocs removed.</p>
<div id="attachment_108" class="wp-caption alignnone" style="width: 549px"><a href="http://erikwramner.files.wordpress.com/2010/10/opmn-active-passive-example.gif"><img src="http://erikwramner.files.wordpress.com/2010/10/opmn-active-passive-example.gif?w=600" alt="Service-failover added, numprocs removed" title="Example of active-passive configuration"   class="size-full wp-image-108" /></a><p class="wp-caption-text">Extract from opmn.xml</p></div>
<p>Failover worked, but sometimes opmn started BOTH instances. Only one should be running. To produce the error:</p>
<p>node 1: <code>opmnctl shutdown</code><br />
(wait until down)<br />
node 2: <code>opmnctl shutdown</code><br />
(wait until down)<br />
node 2: <code>opmnctl startall</code><br />
(wait until up)<br />
node 1: <code>opmnctl startall</code><br />
(wait until up &#8211; running on node 2, stopped on node 1)<br />
node 2: <code>opmnctl stopproc process-type=oc4j_apsa</code><br />
(wait until down &#8211; down on node 2, running on node 1)<br />
node 1: <code>opmnctl stopproc process-type=oc4j_apsa</code><br />
(wait until down &#8211; stopped on both)<br />
node 2: <code>opmnctl startproc process-type=oc4j_apsa</code><br />
(wait until up &#8211; started on BOTH nodes!!!)</p>
<p>The solution was simple, though not obvious. It is not good enough to specify process-type or gid, one has to supply ias-component as well! To start:</p>
<p><code>opmnctl startproc ias-component=apsa_group process-type=oc4j_apsa</code></p>
<p>To stop:</p>
<p><code>opmnctl stopproc ias-component=apsa_group process-type=oc4j_apsa</code></p>
<p>To debug the odd behaviour <code>opmnctl debug</code> was invaluable.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=107&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2010/10/25/pitfall-active-passive-oc4j/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>

		<media:content url="http://erikwramner.files.wordpress.com/2010/10/opmn-active-passive-example.gif" medium="image">
			<media:title type="html">Example of active-passive configuration</media:title>
		</media:content>
	</item>
		<item>
		<title>AQ bulk enqueue/dequeue</title>
		<link>http://erikwramner.wordpress.com/2010/10/11/aq-bulk-enqueuedequeue/</link>
		<comments>http://erikwramner.wordpress.com/2010/10/11/aq-bulk-enqueuedequeue/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 17:01:01 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=104</guid>
		<description><![CDATA[How to perform bulk (array) enqueue and dequeue with AQ.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=104&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Bulk operations can improve performance significantly and (starting with Oracle 10g) it is possible to use them with AQ. An excellent guide can be found <a href="http://www.oracle-developer.net/display.php?id=319">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=104&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2010/10/11/aq-bulk-enqueuedequeue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>
	</item>
		<item>
		<title>Shrink b2b lobs</title>
		<link>http://erikwramner.wordpress.com/2010/06/22/shrink-b2b-lobs/</link>
		<comments>http://erikwramner.wordpress.com/2010/06/22/shrink-b2b-lobs/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 09:46:15 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[B2B]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=97</guid>
		<description><![CDATA[Reclaim wasted space from purged lobs in Oracle B2B<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=97&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sites that use Oracle B2B 10 with reasonable volumes will eventually find that the B2B_LOB tablespace keeps on growing even if the built-in purge job is used. Why? The Oracle database doesn&#8217;t reuse the space from old (deleted) lobs. This is a known peculiarity, check other sources for details.</p>
<p>The fix is straightforward. Shrink space for the two lobs that store payload and wirepayload:</p>
<pre><code>
alter table tip_datastorage_rt modify lob (clobvalue_clob) (shrink space);
alter table tip_datastorage_rt modify lob (blobvalue) (shrink space);
</code></pre>
<p>This can be scheduled as a recurring job or executed manually by a DBA and it can be done online without stopping B2B. To check the amount of storage used before and after, execute as b2b:</p>
<pre><code>
select round(sum(us.bytes/1024/1024)) total_mb
  from user_lobs ul, user_segments us
 where ul.segment_name = us.segment_name
   and ul.table_name = 'TIP_DATASTORAGE_RT';
</code></pre>
<p>For one system the storage used went from 5648M to 16M, quite a respectable saving.</p>
<p>According to Oracle Support (3-1865217281) it is safe to do this. It has intentionally been left out of the purge job, as it is considered to be a task for a DBA.</p>
<p><strong>Note!</strong> Apparently one excellent reason to leave the shrink out of the purge job is that there is a bug in some old Oracle versions that may cause data corruption in lobs after a shrink. Check that you have 10.2.0.4 or better, or alternatively that you have a one-off patch for the relevant bugs fixed in that release.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=97&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2010/06/22/shrink-b2b-lobs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>
	</item>
		<item>
		<title>Find blocking and blocked sessions</title>
		<link>http://erikwramner.wordpress.com/2010/05/28/find-blocking-and-blocked-sessions/</link>
		<comments>http://erikwramner.wordpress.com/2010/05/28/find-blocking-and-blocked-sessions/#comments</comments>
		<pubDate>Fri, 28 May 2010 17:30:53 +0000</pubDate>
		<dc:creator>Erik Wramner</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://erikwramner.wordpress.com/?p=93</guid>
		<description><![CDATA[Useful SQL scripts for finding blocking and blocked sessions and their SQL in an Oracle 10g RAC.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=93&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes a system may grind to a halt or a crawl waiting for database locks. Perhaps a user has left SQL*Plus, TOAD or a similar tool open with uncommitted changes or perhaps an error or oversight in the system itself is causing contention. Regardless the first step is to find out who is holding the locks. The following SQL shows the blocking sessions with a list of all the sessions they block. It works with RAC (the gv views are used rather than v views):</p>
<pre><code>
select s1.sid as blocker_sid,
       s1.username || '@' || s1.machine as blocker_user,
       wm_concat(s2.sid || ':' || s2.username || '@' || s2.machine) as blocked
  from gv$lock l1, gv$session s1, gv$lock l2, gv$session s2
  where s1.sid=l1.sid and s2.sid=l2.sid
    and l1.block=1 and l2.request &gt; 0
    and l1.id1 = l2.id1
    and l2.id2 = l2.id2
  group by s1.sid, s1.username, s1.machine;
</code></pre>
<p>The following SQL shows the most recent SQL executed by sessions holding blocking locks (if available):</p>
<pre><code>
select sid as blocker_sid, wm_concat(sql_text) as blocker_sql
  from (select s.sid, txt.sql_text
          from gv$sqltext txt, gv$session s, gv$lock l
          where txt.address = s.sql_address
          and s.sid = l.sid
          and l.block = 1
          order by s.sid, txt.piece)
  group by sid order by sid;
</code></pre>
<p>Finally the following SQL shows the SQL executed by the sessions that are waiting for blocking locks:  </p>
<pre><code>
select sid as waiting_sid, wm_concat(sql_text) as waiting_sql
  from (select s.sid, txt.sql_text
          from gv$sqltext txt, gv$session s, gv$lock lb, gv$lock lw
          where txt.address = s.sql_address
          and s.sid = lw.sid
          and lw.id1 = lb.id1
          and lb.block = 1
          and lw.request &gt; 0
          order by s.sid, txt.piece)
  group by sid order by sid;
</code></pre>
<p>Armed with this information the root cause is often obvious. The user can be told to commit or rollback, a session can be killed or perhaps an application issue resolved.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/erikwramner.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/erikwramner.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/erikwramner.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/erikwramner.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/erikwramner.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/erikwramner.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/erikwramner.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/erikwramner.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/erikwramner.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/erikwramner.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/erikwramner.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/erikwramner.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/erikwramner.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/erikwramner.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=erikwramner.wordpress.com&amp;blog=12053224&amp;post=93&amp;subd=erikwramner&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://erikwramner.wordpress.com/2010/05/28/find-blocking-and-blocked-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f607cf2dbb6d97eeabb98f085d68c0ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">erikwramner</media:title>
		</media:content>
	</item>
	</channel>
</rss>
