<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3846432405343295844</id><updated>2011-04-21T14:28:50.326-04:00</updated><category term='timeout'/><category term='rails'/><category term='mongrel'/><title type='text'>Yet another [a-z]* blog</title><subtitle type='html'>2.0 and other fun stuff</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://the-mooses-house.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3846432405343295844/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://the-mooses-house.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>thebaldwin</name><uri>http://www.blogger.com/profile/10343240144653351448</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3846432405343295844.post-6650780082331528225</id><published>2008-07-29T23:15:00.003-04:00</published><updated>2008-07-29T23:52:02.355-04:00</updated><title type='text'>why are there empty strings in my not null column?</title><content type='html'>So you're looking at your database and wondering wtf are those default values doing in there?&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-size:78%;"&gt;mysql&gt; create table foo(title char(10) not null);&lt;br /&gt;Query OK, 0 rows affected (0.06 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; insert into foo(title) values (NULL);&lt;br /&gt;ERROR 1048 (23000): Column 'title' cannot be null&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;that was expected...&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-size:78%;"&gt;mysql&gt; insert into foo(title) values (NULL),("OH SNAP");&lt;br /&gt;Query OK, 2 rows affected, 1 warning (0.00 sec)&lt;br /&gt;Records: 2  Duplicates: 0  Warnings: 1&lt;br /&gt;&lt;br /&gt;mysql&gt; show warnings;&lt;br /&gt;+---------+------+-------------------------------+&lt;br /&gt;| Level   | Code | Message                       |&lt;br /&gt;+---------+------+-------------------------------+&lt;br /&gt;| Warning | 1048 | Column 'title' cannot be null |&lt;br /&gt;+---------+------+-------------------------------+&lt;br /&gt;1 row in set (0.00 sec)&lt;/span&gt;&lt;/blockquote&gt;Hmm, not quite what I was expecting...error became a warning..&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-size:78%;"&gt;mysql&gt; select * from foo;&lt;br /&gt;+-----------+&lt;br /&gt;| title &lt;br /&gt;+-----------+&lt;br /&gt;| asdf&lt;br /&gt;|&lt;br /&gt;| OH SNAP&lt;br /&gt;+-----------+&lt;br /&gt;3 rows in set (0.00 sec)&lt;/span&gt;&lt;/blockquote&gt;we get the default empty string inserted for us...how nice&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-size:78%;"&gt;mysql&gt; set sql_mode='TRADITIONAL';&lt;br /&gt;Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;mysql&gt; SELECT @@session.sql_mode;&lt;br /&gt;+-------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;| @@session.sql_mode                                                                                                            |&lt;br /&gt;+-------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;| STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER |&lt;br /&gt;+-------------------------------------------------------------------------------------------------------------------------------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt; &lt;br /&gt;mysql&gt; insert into foo(title) values (NULL),("asdf");&lt;br /&gt;ERROR 1048 (23000): Column 'title' cannot be null&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;woot, stricter now..&lt;br /&gt;&lt;br /&gt;A&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3846432405343295844-6650780082331528225?l=the-mooses-house.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://the-mooses-house.blogspot.com/feeds/6650780082331528225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3846432405343295844&amp;postID=6650780082331528225' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3846432405343295844/posts/default/6650780082331528225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3846432405343295844/posts/default/6650780082331528225'/><link rel='alternate' type='text/html' href='http://the-mooses-house.blogspot.com/2008/07/why-are-there-empty-strings-in-my-not.html' title='why are there empty strings in my not null column?'/><author><name>thebaldwin</name><uri>http://www.blogger.com/profile/10343240144653351448</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3846432405343295844.post-6145383133620112376</id><published>2008-02-18T03:28:00.004-05:00</published><updated>2008-02-18T13:01:00.916-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='timeout'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='mongrel'/><title type='text'>A Couple Of Quick Mongrel Tips</title><content type='html'>&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;timeout mongrel connections&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;There are two time based arguments for your pleasure:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;-o, --timeout X - Time to wait before killing a stalled thread&lt;br /&gt;-t, --throttle X - Time to pause between accepting clients&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Both conveniently begin with the letter 't'. Mistaking -t for the timeout can lead to some interesting behavior like for example causing your site to not accept new clients for a bit.&lt;br /&gt;&lt;br /&gt;If you're looking to timeout your connections after X amount of time you can use -o X, where X is the time to wait in seconds:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;mongrel_rails start -d -e production &lt;span style="font-weight: bold;"&gt;-o 30&lt;/span&gt; -p 5555 -P mongrel.pid&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;stopping a mongrel&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Mongrels dont always like to stop when you tell them to stop, they will just sit there happily forever not doing anything productive:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;% mongrel_rails stop -P mongrel.pid&lt;br /&gt;Sending TERM to Mongrel at PID 25073...Done.&lt;br /&gt;% ps aux | grep '25073'&lt;br /&gt;25073  Feb17   5:51 mongrel_rails [5555/0/8288]: idle  &lt;/blockquote&gt;But I said stop! :(&lt;br /&gt;&lt;br /&gt;You can use --force to send a kill -9, but this isn't too graceful. You want to allow any queued clients to exit before doing this.&lt;br /&gt;&lt;br /&gt;To deal with this you can also provide a wait argument which attempt to do a graceful stop, but if after X amount of time it can't, it will bring out the BFG and kill -9 the process:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;mongrel_rails stop --force -w 30 -P mongrel.pid&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;monitoring a mongrel&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;If you're planning to restart mongrel processes using &lt;a href="http://god.rubyforge.org/"&gt;God &lt;/a&gt;by checking the http status code, make sure you check for more than N consecutive failures as you can(and will) get random timeouts/refused connections.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;restart.condition(:http_response_code) do |c|&lt;br /&gt;c.timeout = 15.seconds&lt;br /&gt;c.code_is_not = 200&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;c.times = [3, 3]&lt;/span&gt;&lt;br /&gt;end&lt;/blockquote&gt;This for example, will check for 3 consecutive http response failures before restarting.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3846432405343295844-6145383133620112376?l=the-mooses-house.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://the-mooses-house.blogspot.com/feeds/6145383133620112376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3846432405343295844&amp;postID=6145383133620112376' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3846432405343295844/posts/default/6145383133620112376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3846432405343295844/posts/default/6145383133620112376'/><link rel='alternate' type='text/html' href='http://the-mooses-house.blogspot.com/2008/02/couple-of-quick-mongrel-tips.html' title='A Couple Of Quick Mongrel Tips'/><author><name>thebaldwin</name><uri>http://www.blogger.com/profile/10343240144653351448</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
