<?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>Cricalix.Net &#187; Code</title>
	<atom:link href="http://www.cricalix.net/categories/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cricalix.net</link>
	<description>Going sane since 1978</description>
	<lastBuildDate>Tue, 23 Mar 2010 07:44:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Zenfolio and taking the leap</title>
		<link>http://www.cricalix.net/archives/2010/01/13/zenfolio-and-taking-the-leap/</link>
		<comments>http://www.cricalix.net/archives/2010/01/13/zenfolio-and-taking-the-leap/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 22:11:31 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[42]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/?p=592</guid>
		<description><![CDATA[Photography, for me, is a hobby verging on a passion; with most of my pleasure coming from shooting at gigs.  I get to hear good music, and I get to hone my skills &#8211; not a bad life really. I&#8217;m also a system administrator, with the ability to write code in a variety of languages, [...]]]></description>
			<content:encoded><![CDATA[<p>Photography, for me, is a hobby verging on a passion; with most of my pleasure coming from shooting at gigs.  I get to hear good music, and I get to hone my skills &#8211; not a bad life really. I&#8217;m also a system administrator, with the ability to write code in a variety of languages, and for over a year now, I&#8217;ve been designing and poking at a dream gallery system that would give the subjects of my photos a measure of control on the distribution of those photos.</p>
<p>This entry isn&#8217;t to announce that I&#8217;ve managed to do that; it&#8217;s the complete opposite.</p>
<p>I&#8217;ve found that <a href="http://www.zenfolio.com/" target="_blank">Zenfolio </a>has come on a long way since I looked at it a year ago.  The Zenfolio service offers custom theming, order fulfillment, password protection, digital licensing and more.  I could, in time, write my own code to do this, but I&#8217;m coming to the realisation that I just don&#8217;t have the energy, nor skill, to write my dream system.  I could probably get my programming up to the skill level required to do it properly, but the time I&#8217;d spend doing that could be spent listening to live music or processing photos from a gig so that I can attempt to earn a little pocket money from them.</p>
<p>I think I&#8217;ll take the live music and pocket money.  I get plenty of chances to excercise my coding streak at work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2010/01/13/zenfolio-and-taking-the-leap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java, I Stab At Thee!</title>
		<link>http://www.cricalix.net/archives/2009/01/31/java-i-stab-at-thee/</link>
		<comments>http://www.cricalix.net/archives/2009/01/31/java-i-stab-at-thee/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 16:15:32 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[$work]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/?p=498</guid>
		<description><![CDATA[I&#8217;m doing some final tuning work on the Puppet recipes for our Glassfish installation, and Java has reared one of its ugly heads again.  In this case, it&#8217;s the whole management of the command line arguments for the JVM.
The majority of the arguments we need to configure take the form
-D$variable=$value
-XX:$variable=$value
The problem is, Java also [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m doing some final tuning work on the Puppet recipes for our Glassfish installation, and Java has reared one of its ugly heads again.  In this case, it&#8217;s the whole management of the command line arguments for the JVM.</p>
<p>The majority of the arguments we need to configure take the form<br />
-D$variable=$value<br />
-XX:$variable=$value</p>
<p>The problem is, Java also has arguments that look like<br />
-X$variable$value</p>
<p>This means my nice simple recipe to deal with tweaking the Glassfish JVM options doesn&#8217;t actually handle all the cases, so I now need to either go write a more complex one (and imbue it with knowledge as to what variables don&#8217;t have equal signs), or write a second recipe with a different name to handle these special snowflake options.</p>
<p>Feh.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2009/01/31/java-i-stab-at-thee/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An opaque Glassfish error</title>
		<link>http://www.cricalix.net/archives/2008/10/13/an-opaque-glassfish-error/</link>
		<comments>http://www.cricalix.net/archives/2008/10/13/an-opaque-glassfish-error/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 09:44:06 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[$work]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[ejb]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/?p=429</guid>
		<description><![CDATA[Doing more testing at work today, and decided to pickup the latest compiled output from the build server.
Exception occured in J2EEC Phasejava.lang.IllegalArgumentException: Unknown ContainerTransaction type [Requires]
com.sun.enterprise.deployment.backend.IASDeploymentException: Error loading deployment descriptors for module [EJB FILE] &#8212; Unknown ContainerTransaction type [Requires]
at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:390)
Pinged one of the developers about that, and apparently it means that the transaction-type in ejb-jar.xml [...]]]></description>
			<content:encoded><![CDATA[<p>Doing more testing at work today, and decided to pickup the latest compiled output from the build server.</p>
<blockquote><p>Exception occured in J2EEC Phasejava.lang.IllegalArgumentException: Unknown ContainerTransaction type [Requires]<br />
com.sun.enterprise.deployment.backend.IASDeploymentException: Error loading deployment descriptors for module [EJB FILE] &#8212; Unknown ContainerTransaction type [Requires]<br />
at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:390)</p></blockquote>
<p>Pinged one of the developers about that, and apparently it means that the transaction-type in ejb-jar.xml is wrong.  Yay.  For a reason I cannot fathom, Google had no results for this error either.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2008/10/13/an-opaque-glassfish-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making OpenNMS faster</title>
		<link>http://www.cricalix.net/archives/2008/09/17/making-opennms-faster/</link>
		<comments>http://www.cricalix.net/archives/2008/09/17/making-opennms-faster/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 15:27:13 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[$work]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[opennms]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/?p=422</guid>
		<description><![CDATA[$work uses OpenNMS to monitor our various devices (servers, switches, routers, printers etc), mostly via SNMP.  Today, while looking at the various events that had been recorded, I noticed that a relatively simple search was taking more than 2 minutes to process through ~250,000 event rows (plus associated rows in other tables).  I turned on [...]]]></description>
			<content:encoded><![CDATA[<p>$work uses <a href="http://www.opennms.org/index.php/Main_Page">OpenNMS</a> to monitor our various devices (servers, switches, routers, printers etc), mostly via SNMP.  Today, while looking at the various events that had been recorded, I noticed that a relatively simple search was taking more than 2 minutes to process through ~250,000 event rows (plus associated rows in other tables).  I turned on query logging (log_statements = &#8216;all&#8217; &amp;&amp; service postgresql reload), and re-ran the search from the web interface.</p>
<p>Lo and behold, the culprit was revealed &#8211; the search went something like</p>
<blockquote><p>UPPER(eventlogmsg) LIKE &#8216;%value%&#8217;</p></blockquote>
<p>Even if that field was indexed,the use of the &#8216;%&#8217; on the front would negate the use of the index.  I threw the query into <a href="http://www.pgadmin.org/">PGAdmin</a>, and discovered that the query plan that PostgreSQL chose was a pair of nested loop joins &#8211; unpleasant to say the least.  A quick gander at the docs, and a few SQL statements later, and I had a full-text index on the eventlogmsg field.  Several test queries convinced me that it was much faster, so I threw the new query into PGAdmin and asked for the pretty query plan.  Two hash joins and a sort, and a query time of 31 milliseconds; or more than 5000 times faster.</p>
<p>So, I&#8217;ve filed a Bugzilla entry for this with the OpenNMS team &#8211; unfortunately it&#8217;s specific to PostgreSQL 8.3, but that&#8217;s something that can probably be determined at run-time and install-time.  Hopefully they agree that it&#8217;s a worthwhile performance change, as full-text indexes won&#8217;t actually help the LIKE usage &#8211; the code will have to change to generate new SQL statements.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2008/09/17/making-opennms-faster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Autostarting Glassfish on CentOS</title>
		<link>http://www.cricalix.net/archives/2008/07/22/autostarting-glassfish-on-centos/</link>
		<comments>http://www.cricalix.net/archives/2008/07/22/autostarting-glassfish-on-centos/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 10:18:03 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[$work]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[glassfish]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/?p=404</guid>
		<description><![CDATA[I&#8217;ve been working with Glassfish recently, from the system administration point of view.  First task, after getting a good build with Maven (doing it with basic rpm methods netted me a massive dependency list, including things like Firefox!), was to write an init script so that Glassfish can be integrated into the CentOS boot sequence.
Because [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with <a href="https://glassfish.dev.java.net/" target="_blank">Glassfish</a> recently, from the system administration point of view.  First task, after getting a good build with Maven (doing it with basic rpm methods netted me a massive dependency list, including things like Firefox!), was to write an init script so that Glassfish can be integrated into the CentOS boot sequence.</p>
<p>Because we might have multiple domains set up inside of Glassfish, I opted for a setup similar to the Tomcat5 init script &#8211; check the basename of $0, and use that to determine which domain to boot up.  The fiddling in start() gets around the fact that Glassfish doesn&#8217;t seem to write a PID file out where we need one.</p>
<p>So, just in case anyone else needs to do this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># chkconfig: 2345 85 15</span>
<span style="color: #666666; font-style: italic;"># description: GlassFish is a Java Application Server.</span>
<span style="color: #666666; font-style: italic;"># processname: glassfish</span>
<span style="color: #666666; font-style: italic;"># pidfile: /var/run/glassfish.pid</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># source function library</span>
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>functions
&nbsp;
<span style="color: #007800;">RETVAL</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">GLASSFISH_BIN</span>=<span style="color: #ff0000;">&quot;/var/lib/glassfish/bin&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Basename works with symbolic links.</span>
<span style="color: #007800;">NAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(basename $0)</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">unset</span> ISBOOT
<span style="color: #666666; font-style: italic;"># Trim off the Sxx/Kxx prefix</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${NAME:0:1}</span>&quot;</span> = <span style="color: #ff0000;">&quot;S&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${NAME:0:1}</span>&quot;</span> = <span style="color: #ff0000;">&quot;K&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">NAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${NAME:3}</span>&quot;</span>
    <span style="color: #007800;">ISBOOT</span>=<span style="color: #ff0000;">&quot;1&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #666666; font-style: italic;"># Trim off the glassfish- prefix</span>
<span style="color: #007800;">NAME</span>=<span style="color: #800000;">${NAME:10}</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># /etc/init.d/glassfish should never be called directly.</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$NAME</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">&quot;Cannot start Glassfish without specifying a domain.&quot;</span>
        failure
        <span style="color: #7a0874; font-weight: bold;">echo</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
start<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">&quot;Starting Glassfish V2 domain <span style="color: #007800;">$NAME</span>: &quot;</span>
        daemon <span style="color: #660033;">--user</span> glassfish <span style="color: #660033;">--pidfile</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>glassfish-<span style="color: #007800;">$NAME</span>.pid <span style="color: #ff0000;">&quot;<span style="color: #007800;">$GLASSFISH_BIN</span>/asadmin start-domain <span style="color: #007800;">$NAME</span> &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&quot;</span>
        <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$RETVAL</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #007800;">PID</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> U glassfish <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$NAME</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$PID</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>glassfish-<span style="color: #007800;">$NAME</span>.pid
                <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>subsys<span style="color: #000000; font-weight: bold;">/</span>glassfish-<span style="color: #007800;">$NAME</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
stop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">&quot;Shutting down Glassfish V2 domain <span style="color: #007800;">$NAME</span>: &quot;</span>
        <span style="color: #007800;">$GLASSFISH_BIN</span><span style="color: #000000; font-weight: bold;">/</span>asadmin stop-domain <span style="color: #007800;">$NAME</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$RETVAL</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>subsys<span style="color: #000000; font-weight: bold;">/</span>glassfish-<span style="color: #007800;">$NAME</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>glassfish-<span style="color: #007800;">$NAME</span>  <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; success <span style="color: #000000; font-weight: bold;">||</span> failure
        <span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
  start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        start
        <span style="color: #000000; font-weight: bold;">;;</span>
  stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        stop
        <span style="color: #000000; font-weight: bold;">;;</span>
  restart<span style="color: #000000; font-weight: bold;">|</span>reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        stop
        start
        <span style="color: #000000; font-weight: bold;">;;</span>
  condrestart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>subsys<span style="color: #000000; font-weight: bold;">/</span>glassfish-<span style="color: #007800;">$NAME</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
            stop
            start
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  status<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        status glassfish-<span style="color: #007800;">$NAME</span>
        <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> $<span style="color: #ff0000;">&quot;Usage: $0 {start|stop|restart|condrestart|status}&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$RETVAL</span></pre></div></div>

<p>The alternative is to define a /etc/sysconfig/glassfish file, and insert a variable with the list of domains to boot, in sequence.  This is a little harder to manage automatically in <a href="http://reductivelabs.com/projects/puppet/" target="_blank">Puppet</a>, but might be a better solution if precise boot sequences are required (this method will boot in sequence based on the S numbers in the base script, and then the alphabetical ordering of the names).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2008/07/22/autostarting-glassfish-on-centos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>On a Heisenbug</title>
		<link>http://www.cricalix.net/archives/2008/05/31/on-a-heisenbug/</link>
		<comments>http://www.cricalix.net/archives/2008/05/31/on-a-heisenbug/#comments</comments>
		<pubDate>Sat, 31 May 2008 17:37:14 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[Avatar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[futex_wait]]></category>
		<category><![CDATA[heisenbug]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/?p=396</guid>
		<description><![CDATA[Over the past few months, the Avatar code has been having a few crashes that leave no recognisable/usable stack for GDB to read.  It&#8217;s also been having a few hangs, with strace indicating futex_wait (in an application that doesn&#8217;t use threads), and gdb of the core (after killing the process) indicating __kernel_vsyscall.  Unfortunately, I&#8217;m not [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few months, the Avatar code has been having a few crashes that leave no recognisable/usable stack for GDB to read.  It&#8217;s also been having a few hangs, with strace indicating futex_wait (in an application that doesn&#8217;t use threads), and gdb of the core (after killing the process) indicating __kernel_vsyscall.  Unfortunately, I&#8217;m not really a programmer/coder, so my efforts to track the cause down have probably been a bit haphazard.</p>
<p>The most annoying part so far is that yesterday we encountered the hang situation 4 times, so I enabled a strace against the binary, and channeled the output across the &#8216;net to my PC where I&#8217;ve got a rolling 40,000 line buffer.  24 hours later, at a constant 2 Mbit/s, and we still haven&#8217;t hung.</p>
<p>I call <a href="http://en.wikipedia.org/wiki/Heisenbug" target="_blank">Heisenbug</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2008/05/31/on-a-heisenbug/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CentOS and LDAP</title>
		<link>http://www.cricalix.net/archives/2008/05/13/centos-and-ldap/</link>
		<comments>http://www.cricalix.net/archives/2008/05/13/centos-and-ldap/#comments</comments>
		<pubDate>Tue, 13 May 2008 11:25:57 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[$work]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/?p=391</guid>
		<description><![CDATA[One of my long-term tickets at work is to provide LDAP or Kerberos integration for our servers at a minimum, and all Linux workstations and laptops if possible.  I poked it a bit today, and made a disappointing discovery.  Unlike Windows, a CentOS machine running LDAP as the primary authentication method is unable to cache [...]]]></description>
			<content:encoded><![CDATA[<p>One of my long-term tickets at work is to provide LDAP or Kerberos integration for our servers at a minimum, and all Linux workstations and laptops if possible.  I poked it a bit today, and made a disappointing discovery.  Unlike Windows, a CentOS machine running LDAP as the primary authentication method is unable to cache the password hash.  So, if I enable it on a laptop, then disconnect that laptop from the network, I am unable to log in as any user that has previously logged in with LDAP credentials.</p>
<p>Bummer.</p>
<p>I doubt Kerberos is going to solve this either, as the caching is performed by nscd, and it&#8217;s nscd that doesn&#8217;t cache the hashes.  I suppose I could work on a custom PAM module that hooks in to pam_ldap, and on successful authentication, stores a new MD5 password for the account in /etc/passwd.  This way, a machine going off-line would have accurate local password hashes, and authentication would still work.</p>
<p>That sounds like way too much work though, and outside the scope of my job.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2008/05/13/centos-and-ldap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back in the coding saddle</title>
		<link>http://www.cricalix.net/archives/2008/01/24/back-in-the-coding-saddle/</link>
		<comments>http://www.cricalix.net/archives/2008/01/24/back-in-the-coding-saddle/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 07:50:30 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Gaming]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/archives/2008/01/24/back-in-the-coding-saddle/</guid>
		<description><![CDATA[Well, one of the things I expected to happen with the job change last year was the return of my energy to write code for random projects.  After several years of coding for a living, any desire to pick up a keyboard and hack on either my own projects ( or public projects ) was [...]]]></description>
			<content:encoded><![CDATA[<p>Well, one of the things I expected to happen with the job change last year was the return of my energy to write code for random projects.  After several years of coding for a living, any desire to pick up a keyboard and hack on either my own projects ( or public projects ) was pretty much non-existent.</p>
<p>I&#8217;ve spent quite a few hours over the past week or so cleaning up the Value Editor mod for the <a href="http://www.eve-dev.net/e107_plugins/forum/forum.php" target="_blank">EVE Killboard</a>, along with patches to the core code, such as implementing the ability to store raw mails and fixing the portrait grabbing code.  I&#8217;ve also spent several hours providing support on the killboard forum for various other users of the software, and I have to say, I&#8217;m quite content now.  There&#8217;s something about providing code (for free) that people find useful.</p>
<p>Not sure what I&#8217;ll tackle next (other than the value editor, it needs a few more tweaks) &#8211; perhaps the mod that shows ship fits as a graphic.  One of the forum users has reported that it whacks their Apache installation load wise.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2008/01/24/back-in-the-coding-saddle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL is Weird</title>
		<link>http://www.cricalix.net/archives/2007/04/11/sql-is-weird/</link>
		<comments>http://www.cricalix.net/archives/2007/04/11/sql-is-weird/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 09:26:24 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[$work]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/archives/2007/04/11/sql-is-weird/</guid>
		<description><![CDATA[Yep, weird with a capital W.
Take two tables.  Un-optimized indexes are present on both tables.  EXPLAIN says 45 rows will be retrieved from one table, 5 from the other.  The 45 will invoke where, the 5 invokes temporary and filesort.
Alter the index on  the table returning 5 rows (it&#8217;s a pivot table).
Now explain says 75, [...]]]></description>
			<content:encoded><![CDATA[<p>Yep, weird with a capital W.</p>
<p>Take two tables.  Un-optimized indexes are present on both tables.  EXPLAIN says 45 rows will be retrieved from one table, 5 from the other.  The 45 will invoke where, the 5 invokes temporary and filesort.</p>
<p>Alter the index on  the table returning 5 rows (it&#8217;s a pivot table).</p>
<p>Now explain says 75, 4, with 75 invoking where, temporary and filesort and 4 invoking where.</p>
<p>Alter the index on the table returning 75 rows so that the index hit picks up the data that&#8217;s getting pivoted.</p>
<p>Now explain says 158, 4 with 158 invoking where, index, temporary, and filesort and 4 invoking where.</p>
<p>The weird part?  The last modification is the fastest, even with no_sql_cache invoked.  More rows to be worked with (arguably it&#8217;s still a small number), but it&#8217;s faster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2007/04/11/sql-is-weird/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL merge tables</title>
		<link>http://www.cricalix.net/archives/2007/03/30/mysql-merge-tables/</link>
		<comments>http://www.cricalix.net/archives/2007/03/30/mysql-merge-tables/#comments</comments>
		<pubDate>Fri, 30 Mar 2007 18:29:15 +0000</pubDate>
		<dc:creator>cricalix</dc:creator>
				<category><![CDATA[$work]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.cricalix.net/?p=301</guid>
		<description><![CDATA[A few years ago, when defining a table, I wasn&#8217;t very savvy to the fact that MySQL uses 4 byte pointers for the MyISAM data files (by default).  This has subsequently bitten me in the rear a few times, enough for me to learn about altering the table with a max_rows argument, and to [...]]]></description>
			<content:encoded><![CDATA[<p>A few years ago, when defining a table, I wasn&#8217;t very savvy to the fact that MySQL uses 4 byte pointers for the MyISAM data files (by default).  This has subsequently bitten me in the rear a few times, enough for me to learn about altering the table with a max_rows argument, and to define the default pointer size in my.cnf.  Unfortunately, the $work installation of MySQL has a bug &#8211; the default pointer size in my.cnf gets ignored.  This leaves me creating all of the various tables with a manually specified max_rows to ensure that I don&#8217;t get bitten.</p>
<p>Enter a legacy table from a few years ago that just hit the pointer limit.  The only solution I had in my arsenal is to rebuild the entire table with a larger pointer size.  The last time I did this, it took 3 days.  3 days to rebuild the indexes for a 4 GB table.  This time around, I tried a method that involves creating a new table definition without the indexes but with larger pointers, copying in all the old data, copying the old index file to the new index file, and executing a repair table.  Unfortunately, while this method is meant to be faster, it only works when you can fit all of the keys into memory, otherwise it uses a slower rebuild method.  2 GB of RAM isn&#8217;t enough to hold all of the keys :(</p>
<p>So, chatting with Dad, he started to say something that tickled the grey cells.  Namely that MySQL has a merge table format that can merge two (or more) identical MyISAM files, and support reads from both underlying files, while specifying where the writes should go.  This means I can create a new underlying table with the new pointer size, then overlay the merge and specify the new table as the target for the writes.  Total time to perform &#8211; 10 seconds, most of which is typing!  Much, much better than 3 days.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cricalix.net/archives/2007/03/30/mysql-merge-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

