<?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>Krzykawski.com</title>
	<atom:link href="http://krzykawski.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://krzykawski.com</link>
	<description>Opensource, work, projects - sharing the fun.</description>
	<lastBuildDate>Wed, 09 Jan 2013 19:54:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>ERROR 1200 (HY000): The server is not configured as slave</title>
		<link>http://krzykawski.com/2012/12/28/error-1200-hy000-the-server-is-not-configured-as-slave/</link>
		<comments>http://krzykawski.com/2012/12/28/error-1200-hy000-the-server-is-not-configured-as-slave/#comments</comments>
		<pubDate>Fri, 28 Dec 2012 20:11:22 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=206</guid>
		<description><![CDATA[So, you&#8217;ve restarted mysqld, and the slave did not start. You issue SHOW SLAVE STATUS\G and notice that everything is fine but &#8220;Slave_IO_Running&#8221; and &#8220;Slave_SQL_Running&#8221; both say &#8220;No&#8221;. You don&#8217;t have skip-slave-start in your my.cnf file. Why did this happen? Baffled- you issue &#8220;START SLAVE;&#8221; and get: ERROR 1200 (HY000): The server is not configured [...]]]></description>
			<content:encoded><![CDATA[<p>So, you&#8217;ve restarted mysqld, and the slave did not start. You issue SHOW SLAVE STATUS\G and notice that everything is fine but &#8220;Slave_IO_Running&#8221; and &#8220;Slave_SQL_Running&#8221; both say &#8220;No&#8221;. You don&#8217;t have skip-slave-start in your my.cnf file. Why did this happen? Baffled- you issue &#8220;START SLAVE;&#8221; and get:<br />
<code>ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO</code></p>
<p>This has happened to me numerous times throughout my time administering mysql servers. It does not happen frequently enough to not baffle you at the first glance, but then you start remembering last time this happened..</p>
<p>The variable server_id always need to be set to something when running replication. Check if server_id is set by issuing &#8220;SHOW VARIABLES LIKE &#8216;server_id&#8217;;. The value should not be &#8220;0&#8243; or &#8220;1&#8243;. &#8220;1&#8243; is normally set by default. Also, the master&#8217;s server_id and the slave&#8217;s server_id should not be the same.</p>
<p>You can set the server id by issuing &#8220;SET GLOBAL server_id=<number>;&#8221; then issue a START SLAVE;</p>
<p>We should be fine now.. </p>
<p>Ugh, I know this is fairly easy to find, but in an attempt to have this fresher in memory, a quick blog post helps remembering. <img src='http://krzykawski.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2012/12/28/error-1200-hy000-the-server-is-not-configured-as-slave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPCOP install on headless device with serial console (ALIX 2D13)</title>
		<link>http://krzykawski.com/2011/12/27/ipcop-install-on-headless-device-with-serial-console-alix-2d13/</link>
		<comments>http://krzykawski.com/2011/12/27/ipcop-install-on-headless-device-with-serial-console-alix-2d13/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 11:07:43 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=191</guid>
		<description><![CDATA[In the voyage of choosing OS to run on this device, I realized I need a easy way to install OS&#8217;es onto the CF card. Now, this system does not have any display output other than serial; Any boot loader (in my case GRUB) needs to be aware of that. The easiest way to try [...]]]></description>
			<content:encoded><![CDATA[<p>In the voyage of choosing OS to run on this device, I realized I need a easy way to install OS&#8217;es onto the CF card. Now, this system does not have any display output other than serial; Any boot loader (in my case GRUB) needs to be aware of that.</p>
<p>The easiest way to try different OS&#8217;es is to have the installation media network mounted, and just PXE boot the device, choosing OS in pxelinux.cfg (if trying linux OS&#8217;es that is). I set it up as follows (since I have a ubuntu machine anyway), but a similar approach will work for other distribution/OS&#8217;es. You will need to install a tftp server, dhcp server and a http server. Your &#8220;server&#8221; which will serve these three services need to have a static IP and other dhcp servers need to be turned off on that network.</p>
<p>&nbsp;</p>
<p>1) Make sure your ALIX is ready with the CF card inserted, and network cable connected to your first/rightmost interface (closest to the power input)<br />
2) Setup and start a tftp server on the machine you will be using as a server. On ubuntu, the easiest way would be using</p>
<blockquote><p>apt-get install &lt;package&gt;</p></blockquote>
<p>I chose &#8220;tftp-hpa&#8221;<br />
3) Setup and start a http server on the machine you will be using as a server. You might already have one running, so check before. I already had lighttpd running.<br />
4) Setup and start a dhcp server on your network. Either on you server or if you have a dhcp server, make sure it can swallow options for PXE clients. I used the ISC dhcp server on the same host as above. Package: isc-dhcp-server<br />
5) Download ipcop-&lt;version&gt;-install-netboot.i486.tgz and ipcop-&lt;version&gt;-install-cd.i486.iso to your server host.<br />
6) Untar the first (netboot install file) to the tftp root, then copy the &#8220;ipcop-pxe-serial-&lt;version&gt;.model&#8221; file to &#8220;default&#8221; in the same directory, then copy the &#8220;pxelinux.0&#8243; file in &#8220;&lt;tft-root&gt;/ipcop/&lt;version&gt;/i486/pxelinux.0&#8243; to your tftp root<br />
7) Make ipcop iso available via your http server either by copying the contents of the iso to a directory in the http root, or mount it to a directory in your http root. I symlinked my mount to ipcop_iso in the root.<br />
 <img src='http://krzykawski.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> Configure your dhcp server to have your tftp servers ip as &#8220;next-server&#8221; and make sure to pass the pxelinux.0 file in the config for pxe as well. I added these lines to dhcpd.conf: </p>
<blockquote><p>
next-server &lt;my.servers.ip.address&gt;;<br />
host alix {<br />
    hardware ethernet &lt;mac address of the alix&gt;;<br />
    filename &#8220;pxelinux.0&#8243;;<br />
}
</p></blockquote>
<p>9) Connect the ALIX using serial to a machine with a serial port (maybe your server above), and fire up your choice of serial terminal. I used minicom, and since I don&#8217;t have a serial port but a USB to SERIAL converter, the device was specified as the device created when the converter was inserted: </p>
<blockquote><p>minicom &#8211;device /dev/ttyUSB0 &#8211;baudrate 38400 &#8211;8bit &#8211;statline&#8221;</p></blockquote>
<p>10) Connect power to your ALIX board. You should see output on your serial terminal immediately. Something like this:</p>
<blockquote><p>PC Engines ALIX.2 v0.99h<br />
640 KB Base Memory<br />
261120 KB Extended Memory.
</p></blockquote>
<p>Press &#8220;S&#8221; to enter bios configuration, &#8220;E&#8221; to enable PXE boot and &#8220;Q&#8221; to quit, choosing &#8220;Y&#8221; on the &#8220;Do you want to save&#8221; prompt.</p>
<p>Your ALIX board should now PXE boot. Follow the install instructions. You will get prompted what media you want to use to install. Choose HTTP and enter the server where you put your ipcop iso, together with the full http path. If your ALIX board did not PXE boot, search the logs and check your DHCP/tftp setup. These are the only ones used during PXE boot.</p>
<p>Now, I had issues with ipcop not wanting to boot after the install. I got Boot error straight after the POST sequence. I am running a 8GB CF card, and though that might be an issue (since IPCOP docs state it supports cards up to 4GB), but after mocking around a bit, I decided to re-install &#8211; and that solved it (ugh..). I am guessing something failed during the first installs MBR write to the CF card. I can&#8217;t really re-wind now and check the MBR out.. Should have done that in the first place.. I did however get a tip (on the ipcops.com forum) to update to the latest ALIX bios (which I already had on the board). tinyBIOS 0.99h.</p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2011/12/27/ipcop-install-on-headless-device-with-serial-console-alix-2d13/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Home Project; Router/WiFi AP/Server on ALiX 2D13</title>
		<link>http://krzykawski.com/2011/12/22/home-project-routerwifi-apserver-on-alix-2d13/</link>
		<comments>http://krzykawski.com/2011/12/22/home-project-routerwifi-apserver-on-alix-2d13/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 19:03:00 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=177</guid>
		<description><![CDATA[Background: So, after a trying a couple of different AP&#8217;s, and realizing they were either unstable or lacking important features; I decided to build my own. It&#8217;s apparently not that easy to find a nice and stable AP/router/switch nowadays. You can&#8217;t just go and buy one for $100-$150 and expect it to be stable. And [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Background</strong>:</p>
<p>So, after a trying a couple of different AP&#8217;s, and realizing they were either unstable or lacking important features; I decided to build my own. It&#8217;s apparently not that easy to find a nice and stable AP/router/switch nowadays. You can&#8217;t just go and buy one for $100-$150 and expect it to be stable. And by stable I mean not being forced to power-cycle the device every couple of days.</p>
<p>After my last <em>D-Link (DGL-4100)</em> died, I bought myself a corporate grade <em>Cisco/Linksys device (WRV200)</em>. It promised a lot of what I wanted from a device like that, and it gave me the option to setup VPN (road warrior style and site-2-site). <strong>FAIL</strong>! -&gt; It promised, but did not live up to my expectations; Sure, you were able to du all of what it promised, but if you started to use it for real, the poor router overheated and hanged. Since I bought 3 of these to interconnect 3 sites using VPN, I was not very happy.. Took a while to have them returned.. Going through the procedure of proving they did not live up to the promises made..</p>
<p>I ended up researching alternatives, and found mikrotik (www.mikrotik.com) and their line of hardware; routerboards (www.routerboard.com). I wasn&#8217;t sure about if I would like running a scaled down and restricted linux based router os where I could not alter things I wanted; but after trying it for a month or so, I decided to buy one and play around with.. Now, I thought the RB493UAH that I got delivered was a broken promise too, as it was hanging after just half a day of heavy use. This proved to be a hardware error, and I got a new one sent out without having to return the old one in advance. Great service here! Anyway, the second one has been up and running for 2.5 years without having to reboot. Firewalling, connection tracking, and all that jazz is enabled and I still get 100mbps throughput in between all interfaces. Torrenting with 300-400-500 simultaneous connections from more than one internal host is smooth and I get maximum throughput both ways (in/out) duplex. I also have one wireless card in it, and am adding a new 802.11N card in the next couple of weeks. Anyway, I finally ended up getting 2x RB433UAH, with various wireless cards, and am running VPN in between sites just fine as well. whee..</p>
<p><strong>ALIX 2D13</strong>:</p>
<p>Since I already have been playing around with my fit-pc slim for the past 3.5 years, and it&#8217;s been a fun little device; I decided to try a new router/ap/server project. I bought a ALIX 2D13 board (based on the same AMD Geode CPU &#8211; LX800 and chipset &#8211; CS5536; as the fit-pc slim), 8GB of 30MB/s flash, a TP-Link wireless N card and some other nick-nack&#8217;s to get things going.. I agree it feels kinda old to buy a new device (3.5 years later) with the same old cpu as my old fit-pc slim, but it&#8217;s been 100% stable running ubuntu 8.04 from start.</p>
<p>I have not decided what OS I will be running, but will mess around with it in the free days around x-mas. Options I am looking at are:</p>
<p><em><a href="http://www.ipcop.org">IPCop</a>, <a href="http://www.ipfire.org">IPFire</a>, <a href="http://alpinelinux.org">AlpineLinux</a>, <a href="http://linux.voyage.hk/">VoyageLinux</a>, <a href="http://openwrt.org">OpenWRT</a>, <a href="http://ubuntu.com/">Ubuntu</a>, <a href="http://linuxmint.com/">Linux Mint</a> or <a href="http://www.freebsd.org">FreeBSD</a></em>.. I&#8217;ve been considering <em><a href="http://pfsense.org">pfSense</a> and <a href="http://m0n0wall.ch">m0n0wall</a></em> but they are just to0 scaled down. I want to be able to do more than just a router/ap.<br />

<a href='http://krzykawski.com/2011/12/22/home-project-routerwifi-apserver-on-alix-2d13/photo-11/' title='photo (11)'><img width="150" height="150" src="http://krzykawski.com/wp-content/2011/12/photo-11-150x150.jpg" class="attachment-thumbnail" alt="photo (11)" title="photo (11)" /></a>
<a href='http://krzykawski.com/2011/12/22/home-project-routerwifi-apserver-on-alix-2d13/photo-12/' title='photo (12)'><img width="150" height="150" src="http://krzykawski.com/wp-content/2011/12/photo-12-150x150.jpg" class="attachment-thumbnail" alt="photo (12)" title="photo (12)" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2011/12/22/home-project-routerwifi-apserver-on-alix-2d13/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So random</title>
		<link>http://krzykawski.com/2011/07/07/so-random/</link>
		<comments>http://krzykawski.com/2011/07/07/so-random/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 10:13:01 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=174</guid>
		<description><![CDATA[The weather here in London is so random I don&#8217;t know where to begin.. Not to go into to much detail; I look out the window before I leave for work, and it&#8217;s cloudy, but no rain and the streets are dry.. I take the elevator down, pass through the lobby, open the door and [...]]]></description>
			<content:encoded><![CDATA[<p>The weather here in London is so random I don&#8217;t know where to begin.. Not to go into to much detail;</p>
<p>I look out the window before I leave for work, and it&#8217;s cloudy, but no rain and the streets are dry..</p>
<p>I take the elevator down, pass through the lobby, open the door and am faced with hard rain. I turn around to get a different jacket (one with a hood).</p>
<p>Get up to the apartment, put a hoodie on and get out again. Pass the lobby, open the door &#8211; no rain.. I walk to the subway (tube), take jubilee line then change in green park for piccadilly. Arrive in leicester square 20 minutes later, get out of the tube station and it&#8217;s pouring down again.. ugh..</p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2011/07/07/so-random/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interesting new thread..</title>
		<link>http://krzykawski.com/2011/04/16/interesting-new-thread/</link>
		<comments>http://krzykawski.com/2011/04/16/interesting-new-thread/#comments</comments>
		<pubDate>Sat, 16 Apr 2011 21:12:03 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[Confereces]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=163</guid>
		<description><![CDATA[Concluded the MySQL UC (called the O&#8217;Reilly MySQL Conference &#38; Expo nowadays).. There was a lot of interesting stuff going on, and was great to get a refresher.. It was also a useful &#8220;see how others do it&#8221; exercise. Something that come to mind is the new threads added in InnoDB. To bad they show up [...]]]></description>
			<content:encoded><![CDATA[<p>Concluded the MySQL UC (called the O&#8217;Reilly MySQL Conference &amp; Expo nowadays).. There was a lot of interesting stuff going on, and was great to get a refresher.. It was also a useful &#8220;see how others do it&#8221; exercise.</p>
<p>Something that come to mind is the new threads added in InnoDB. To bad they show up first in 5.6.2+. We would have needed them now.. <img src='http://krzykawski.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  But isn&#8217;t that always the case? We are facing the trouble of grooming a table from loads of historical data. It&#8217;s running InnoDB, so we all know it&#8217;s kinda expensive to do massive deletes from it. Especially if you&#8217;re not doing it on your PK. We were debating how to setup a groomer job on a table like this, and no matter how we do it, the only feasible way is to delete by PK. Massive data deletes will still cause for performance degradation when the pages become to dirty. This has of course changed in the new additions to InnoDB in 5.6.2+. Deleting by PK is still the fastest way, and will be faster when we one day switch to 5.6.x. Read more about the new InnoDB stuff here: <a href="http://blogs.innodb.com/wp/2011/04/introducing-page_cleaner-thread-in-innodb/" target="_blank">InnoDB Page Cleaner Thread</a></p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2011/04/16/interesting-new-thread/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL UC 2011 Concluded.</title>
		<link>http://krzykawski.com/2011/04/16/mysql-uc-2011-concluded/</link>
		<comments>http://krzykawski.com/2011/04/16/mysql-uc-2011-concluded/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 23:37:58 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[Confereces]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=165</guid>
		<description><![CDATA[MySQL UC 2011 (Now called O&#8217;Reilly MySQL Conference &#38; Expo) concluded yesterday. It was for sure a very rewarding conference, but one may debate the absence of MySQL itself (Oracle). Normally there is a lot going on, and a lot of announcements from MySQL. In this case Oracle owns MySQL. I don&#8217;t know if they [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL UC 2011 (Now called O&#8217;Reilly MySQL Conference &amp; Expo) concluded yesterday.</p>
<p>It was for sure a very rewarding conference, but one may debate the absence of MySQL itself (Oracle). Normally there is a lot going on, and a lot of announcements from MySQL. In this case Oracle owns MySQL. I don&#8217;t know if they are trying to make a statement, not showing up and providing information to the community. Or are they to self absorbed, and want to pull Open database people to join on Oracle World? I don&#8217;t know, and I really hope it&#8217;s not the latter. They seem to put a lot of money and effort into continued development of MySQL and InnoDB.</p>
<p>Monty did a bald move in his keynote, and later had to appologize in a public blog post: <a href="http://monty-says.blogspot.com/" target="_blank">monty says</a>. Me and Tobias Asplund had a decent chat with him at the SkySQL dinner, and there is a lot of new interesting stuff happening in MariaDB. A lot of effort has been put into subquery optimization and the execution plans are now better than ever. Hopefully Oracle will not be too scared to adopt those patches. We will have to try MariaDB here at Marin to see if we&#8217;ll get any performance improvements running subqueries. It&#8217;s not a production test just to calm those worried souls. <img src='http://krzykawski.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I enjoyed Yoshinori Matsunobo&#8217;s Tutorial. There was a lot of refreshing material, but also some new things I have not been able to test before. Good stuff! Check out <a href="http://yoshinorimatsunobu.blogspot.com/" target="_blank">Matsunobos blog</a></p>
<p>I also enjoyed many of the facebook talks. It&#8217;s very giving to see how they attack some of the problems others never see. The amount of servers and data those guys are handling is insane. Their data drift spotting stuff was awesome as well.</p>
<p>I am surprised by the amount of people looking for DBA&#8217;s or data architects. Almost all talks or keynotes said they were hiring.</p>
<p>All in all, it was a great conference. I am almost looking forward to the next one. <img src='http://krzykawski.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2011/04/16/mysql-uc-2011-concluded/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable iPhone Emoji (smiley) icons</title>
		<link>http://krzykawski.com/2010/12/09/enable-iphone-emoji-smiley-icons/</link>
		<comments>http://krzykawski.com/2010/12/09/enable-iphone-emoji-smiley-icons/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 15:31:12 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[iPhone/iPad]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=157</guid>
		<description><![CDATA[I successfully enabled the Emoji keyboard on my iPhone4, making it possible to use a lot of different funny icons in SMS, MMS, email, notes, well, wherever you type something in your phone. There are applications in the app store that will help you do this (cost money), but there is one free application that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://krzykawski.com/wp-content/2010/12/IMG_0851x.png"><img class="alignleft size-thumbnail wp-image-158" title="IMG_0851x" src="http://krzykawski.com/wp-content/2010/12/IMG_0851x-150x150.png" alt="" width="150" height="150" /></a>I successfully enabled the Emoji keyboard on my iPhone4, making it possible to use a lot of different funny icons in SMS, MMS, email, notes, well, wherever you type something in your phone. There are applications in the app store that will help you do this (cost money), but there is one free application that has a &#8220;easter egg&#8221; (hidden feature) which will do this for you. This application is called SpellNumber.</p>
<p>Once you download this app, launch it and enter this secret number: 91929394.59 followed by enter (once). Quit the app (pressing the home button) and reboot your phone (iOS 4.x caches available keyboards, so reboot is needed). Once rebooted, enter Settings -&gt; General -&gt; International -&gt; Keyboards -&gt; Add new keyboard. You should have a keyboard named Emoji there. Enable it, and whoops; You have Emoji icons. (you touch the globe icon just beside the spacebar to switch between keyboards)</p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2010/12/09/enable-iphone-emoji-smiley-icons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UPDATE on huge table without index</title>
		<link>http://krzykawski.com/2010/09/15/update-on-huge-table-without-index/</link>
		<comments>http://krzykawski.com/2010/09/15/update-on-huge-table-without-index/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 13:10:45 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=143</guid>
		<description><![CDATA[This is something that keeps coming back no matter where I work. It&#8217;s always something I do the same, but it takes a minute to remember how I did it last time. I guess it&#8217;s time to share something super easy. Scenario: You have a huge table with constant activity, containing terabytes of data. You [...]]]></description>
			<content:encoded><![CDATA[<p>This is something that keeps coming back no matter where I work. It&#8217;s always something I do the same, but it takes a minute to remember how I did it last time. I guess it&#8217;s time to share something super easy.</p>
<p><strong>Scenario:</strong><br />
You have a huge table with constant activity, containing terabytes of data. You need to update/delete roughly a million random rows. Random selects from the table keep some indexes you could use hot. Running a big update, locking rows/table is not an option since you have approx. 40-50 inserts/sec to the table. So you need to run smaller batches when updating table. LIMIT would be nice, but is not supported with OFFSET when using UPDATE or DELETE.</p>
<p>Updating using IN and subquery together with limit is not supported in 5.0.x (usure about 5.1.x and forward), Else this would have been a viable solution.</p>
<p>Selects with specific where clauses might take longer due to some indexes/keys being too big as well</p>
<p><strong>Solution:</strong><br />
Selecting all Unique/Primary keys to a temp table with an auto increment primary key and then update the production table using this temporary table as a reference table to which rows to update, with a BETWEEN clause on the temporary table&#8217;s auto_increment field.<br />
May also enclose everything in a transaction and delete the same &#8216;between&#8217; on the temporary reference table. Will help you keep track of what you actually did in case you need to abort this.</p>
<p><strong>Example</strong><br />
Production table:</p>
<blockquote><p>CREATE TABLE `huge_table` (<br />
`request_id` bigint(20) NOT NULL auto_increment,<br />
`customer_id` int(11) default NULL,<br />
`data_id` bigint(20) default NULL,<br />
`group_id` int(11) default NULL,<br />
`user_id` int(11) default NULL,<br />
`action_id` int(11) default NULL,<br />
`external_id` int(11) default NULL,<br />
`user_data` varchar(2048) default NULL,<br />
`entry` text,<br />
`extra_term` varchar(255) default NULL,<br />
`transaction` text,<br />
`receive_time` datetime default NULL,<br />
`from_id` varchar(32) default NULL,<br />
`url` varchar(2048) default NULL,<br />
`from_ip` varchar(2048) default NULL,<br />
`useragent` varchar(2048) default NULL,<br />
`tz` int(11) default NULL,<br />
`cvalue` varchar(255) default NULL,<br />
`rvalue` varchar(255) default NULL,<br />
`uid` varchar(40) default NULL,<br />
PRIMARY KEY  (`request_id`),<br />
KEY `k1` (`receive_time`,`action_id`,`url`,`from_id`)<br />
) ENGINE=InnoDB AUTO_INCREMENT=1047142423 DEFAULT CHARSET=utf8</p></blockquote>
<p>You need to update action_id = 100 on approx 1.5m rows which have receive_time between &#8217;2010-08-01 00:00:00&#8242; and &#8217;2010-08-31 23:59:59&#8242; where from_id equals &#8216;q7b4x5aa0303erer&#8217;.</p>
<p>temporary table:</p>
<blockquote><p>CREATE TABLE `tmp_ids` (<br />
`id` int(11) NOT NULL auto_increment,<br />
`prod_id` bigint(20) default NULL,<br />
PRIMARY KEY  (`id`)<br />
) ENGINE=MyISAM AUTO_INCREMENT=15424160 DEFAULT CHARSET=utf8</p></blockquote>
<p>Fill the temporary table with the id&#8217;s you need to update in the production table:</p>
<blockquote><p>INSERT INTO tmp_ids SELECT * FROM huge_table USE INDEX (k1) WHERE from_id=&#8217;q7b4x5aa0303erer&#8217; AND receive_time BETWEEN &#8217;2010-08-01 00:00:00&#8242; AND &#8217;2010-08-31 23:59:59&#8242;;</p></blockquote>
<p>Then just iterate this in a bash script or our favorite scripting language (increasing the between values of course):</p>
<blockquote><p>UPDATE huge_table ht JOIN tmp_ids ti ON ht.request_id=ti.prod_id SET ht.action_id=100 WHERE ti.id BETWEEN x AND x;</p></blockquote>
<p>example bash script:</p>
<blockquote><p>#!/bin/bash</p>
<p># Config params<br />
user=&#8221;username&#8221;<br />
pass=&#8221;password&#8221;<br />
host=&#8221;hostname&#8221;<br />
db=&#8221;schema_name&#8221;<br />
tmptbl=&#8221;tmp_table&#8221;<br />
livetbl=&#8221;live_table&#8221;<br />
tmpcol=&#8221;live_id&#8221;<br />
livecol=&#8221;request_id&#8221;<br />
tmpkey=&#8221;id&#8221;<br />
upcol=&#8221;from_id=1&#8243;<br />
waittime=&#8221;0.5&#8243;</p>
<p># Print usage function<br />
function usage() {<br />
	echo &#8220;$(basename $0) <rows>&#8221;<br />
	echo &#8220;rows &#8211; number of rows in one go.&#8221;<br />
	exit 0<br />
}</p>
<p># Since we need atleast one variable to continue, check so first variable is supplied<br />
[ -e $1 ] &#038;&#038; usage &#038;&#038; exit</p>
<p># get that variable<br />
rows=$1<br />
# Check which is the first key we will use in temp table<br />
s=`mysql -N -u$user -p$pass -h$host $db -e&#8221;select min(id) from $db.$tmptbl;&#8221;`<br />
# Set latter between value<br />
let b=$s+$rows;<br />
# Count how many rows we have to update so we know how long to loop<br />
count=`mysql -N -u$user -p$pass -h$host $db -e&#8221;select count(*) from $db.$tmptbl;&#8221;|head`;</p>
<p># Print starting line<br />
echo &#8220;Starting up with updates from id: $s to $b, performing $rows at one go..&#8221;</p>
<p># loop till we are done<br />
while [ 1 ];<br />
do</p>
<p># are we done? If so exit<br />
	if (($count <= 0));<br />
		then<br />
		exit<br />
	fi</p>
<p># Run actual db updates<br />
	echo -n "updating $livetbl between $s and $b.."<br />
	mysql -N -u$user -p$pass -h$host $db -e"update $livetbl td join $tmptbl i on td.$livecol=i.$tmpcol set $setval where i.$tmpkey between $s and $b"<br />
	echo -n " deleting in $tmptbl.."<br />
	mysql -N -u$user -p$pass -h$host $db -e"delete from $db.$tmptbl where $tmpkey between $s and $b"<br />
	echo -n " Done!"</p>
<p># set between rows<br />
	let s=$s+$rows<br />
	let b=$b+$rows<br />
	let count=$count-$rows</p>
<p># wait if there are more records to update<br />
	if (($count > 0));<br />
	then<br />
		echo &#8221; ..waiting.. still $count records to update&#8221;;<br />
		sleep $waittime<br />
	fi<br />
done</p>
<p># All done<br />
echo &#8220;Script done. No more records to update&#8221;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2010/09/15/update-on-huge-table-without-index/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone time zone issue &#8211; Resolved</title>
		<link>http://krzykawski.com/2010/09/06/iphone-time-zone-issue-resolved/</link>
		<comments>http://krzykawski.com/2010/09/06/iphone-time-zone-issue-resolved/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 15:45:52 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Travel]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=135</guid>
		<description><![CDATA[So, ever since I got my iPhone 4, i have had issues where my calendar have been showing and alerting me about my appointments one hour ahead. I could enter an appointment today at 5pm on my phone, choosing to alert 30 minutes ahead of the appointment &#8211; The result would be that the phone [...]]]></description>
			<content:encoded><![CDATA[<p>So, ever since I got my iPhone 4, i have had issues where my calendar have been showing and alerting me about my appointments one hour ahead.</p>
<p>I could enter an appointment today at 5pm on my phone, choosing to alert 30 minutes ahead of the appointment &#8211; The result would be that the phone would alert me at 3:30pm instead of 4:30pm. Even though it showed the correct time in the calendar on the phone.</p>
<p>On a side note, both MobileMe and our company&#8217;s Exchange would save the appointment at 4pm. Now, this has to do with my timezone settings. I was playing around with that, but no real change.. It was always displaying one hour wrong from what I entered. Also, if i entered an appointment the right time in any of the above calendars, the iPhone calendar would show one hour in advance.<a href="http://krzykawski.com/wp-content/2010/09/IMG_0632.png"><img class="alignright size-thumbnail wp-image-136" title="IMG_0632" src="http://krzykawski.com/wp-content/2010/09/IMG_0632-150x150.png" alt="Phone screenshot-tz" width="150" height="150" /></a></p>
<p>I booked an appointment at the genius bar at apple, and they were as stunned as me.. But playing around in the phone together we found a second time zone setting in: Settings-&gt;Mail, Contacts, Calendar called Time Zone Support. Apparently, if you want time zones to work when you travel (to have your appointments at the right time where you are located), you have to turn Time Zone Support OFF! (?). This will change the appointments to the time you are when you move between time zones.</p>
<p>I guess I might not be the only one with these issues.. So sharing.. <img src='http://krzykawski.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2010/09/06/iphone-time-zone-issue-resolved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle.. And so it begins..</title>
		<link>http://krzykawski.com/2010/08/13/oracle-and-so-it-begins/</link>
		<comments>http://krzykawski.com/2010/08/13/oracle-and-so-it-begins/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 10:20:21 +0000</pubDate>
		<dc:creator>robertk</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://krzykawski.com/?p=128</guid>
		<description><![CDATA[Oracle sues Google over Android and Java Ever since Oracle announced the acquisition of Sun Microsystems, I have been thinking somthing like this would happen. Oracle is not exactly known for contributing to the Open Source community, even if they claim they are committed to helping and enhancing it. It feels like their ultimate goal [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://news.cnet.com/8301-30684_3-20013546-265.html" target="_blank">Oracle sues Google over Android and Java</a></p>
<p>Ever since Oracle announced the acquisition of Sun Microsystems, I have been thinking somthing like this would happen. Oracle is not exactly known for contributing to the Open Source community, even if they claim they are committed to helping and enhancing it. It feels like their ultimate goal is to close source everything. I can&#8217;t understand the nature of such an organization. Isn&#8217;t shared knowledge, more knowledge? We all want to evolve, and what better way than <span style="text-decoration: underline;">not</span> inventing the wheel over and over again. Soon Oracle will want you to pay a license fee for every execution of your java application (per processor) <img src='http://krzykawski.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I am dreading what they will do with MySQL when they get there.. Same licensing model as Oracle DB? <img src='http://krzykawski.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Just had to comment on this, as I think it is ridiculous and def. not adding anything to the community.</p>
]]></content:encoded>
			<wfw:commentRss>http://krzykawski.com/2010/08/13/oracle-and-so-it-begins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
