<?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>eXpand yOur cReativity &#187; active_record_store</title>
	<atom:link href="http://blog.bhushangahire.net/tag/active_record_store/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bhushangahire.net</link>
	<description></description>
	<lastBuildDate>Thu, 05 Jan 2012 07:17:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Rails active_record_store &amp; Segmentation fault</title>
		<link>http://blog.bhushangahire.net/2008/02/25/rails-active_record_store-segmentation-fault/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rails-active_record_store-segmentation-fault</link>
		<comments>http://blog.bhushangahire.net/2008/02/25/rails-active_record_store-segmentation-fault/#comments</comments>
		<pubDate>Mon, 25 Feb 2008 07:52:17 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[active_record_store]]></category>
		<category><![CDATA[segmentation fault]]></category>

		<guid isPermaLink="false">http://www.bhushangahire.net/2008/02/25/rails-active_record_store-segmentation-fault/</guid>
		<description><![CDATA[Here&#8217;s a quick tip if you&#8217;re getting errors like this one in your Rails application: /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session/active_record_store.rb:84: [BUG] Segmentation fault The most probable reason you&#8217;re getting the Segmentation fault and your server crashes is because you&#8217;re trying to store too much data in sessions table of your application (I assume you are using active_record_store as a [...]]]></description>
			<content:encoded><![CDATA[<p class="entry">Here&#8217;s a quick tip if you&#8217;re getting errors like this one in your Rails application:</p>
<blockquote><p>/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session/active_record_store.rb:84: [BUG] Segmentation fault</p></blockquote>
<p>The most probable reason you&#8217;re getting the Segmentation fault and your server crashes is because you&#8217;re trying to store too much data in sessions table of your application (I assume you are using active_record_store as a session store).</p>
<p>The problem with &#8220;too much data&#8221; is that by default, the session table creation rake task created the following migration in Rails 1.x:</p>
<blockquote><p>class AddSessions &lt; ActiveRecord::Migration<br />
def self.up</p>
<p>create_table :sessions do |t|<br />
t.column :session_id, :string<br />
<strong> t.column :data, :text</strong><br />
t.column :updated_at, :datetime<br />
end<br />
add_index :sessions, :session_id<br />
end</p>
<p>def self.down</p>
<p>drop_table :sessions<br />
end<br />
end</p></blockquote>
<p>Please note the data field defined as text. This means that it can only store up to 64Kb of data. And that also means that if you&#8217;re trying to store more than 64Kb in your session.</p>
<p>In order to fix the problem, you just need to manually change the column type before you run migration which creates session store, or just create a new migration which changes parameters of the data column in existing sessions table:</p>
<p>Should look something like that (Rails 2 syntax):</p>
<blockquote><p>class CreateSessions &lt; ActiveRecord::Migration<br />
def self.up</p>
<p>drop_table :sessions</p>
<p>create_table :sessions do |t|<br />
t.string :session_id, :null =&gt; false<br />
<strong> t.column :data, :binary, :limit =&gt; 10.megabyte</strong><br />
t.timestamps<br />
end</p>
<p>add_index :sessions, :session_id<br />
add_index :sessions, :updated_at<br />
end</p>
<p>def self.down<br />
drop_table :sessions<br />
end<br />
end</p></blockquote>
<p>Empty your sessions table, restart your server and you&#8217;re done. No more segmentation faults. Of course you shouldn&#8217;t store that much data in a session in the first place.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2008/02/25/rails-active_record_store-segmentation-fault/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

