Skip to content

Sqlite3+DevEnv+Rails-3.1rc1 = leaks memory and craps out in seconds! #1289

Closed
xanview opened this Issue May 25, 2011 · 7 comments

6 participants

@xanview
xanview commented May 25, 2011

Steps to reproduce:

Step 1

From 192.168.0.7 - running Rails 3.1rc1 on a clean Ubuntu 11.04 with Ruby installed with rvm install 1.9.2

rails new blankapp
cd blankapp
rails g scaffold myapp myfield:string
rake db:migrate
rails s

Step 2

From 192.168.0.1 (on the same network

curl -d '{"myfield":"test value"}' -H 'Content-Type: application/json' -H 'Accept: application/json' http://192.168.0.7:3000/myapps
{"created_at":"2011-05-25T05:23:49Z","id":1,"myfield":"test value","updated_at":"2011-05-25T05:23:49Z"}
...
while true; do curl http://192.168.0.7:3000/myapps/1; done
...

Step 3

From 192.168.0.7 - Memory use climbs to around 350MB... rails craps out after as little as a few seconds of requests!

curl http://192.168.0.7:3000/myapps/1
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Action Controller: Exception caught</title>
  <style>
    body { background-color: #fff; color: #333; }

    body, p, ol, ul, td {
      font-family: helvetica, verdana, arial, sans-serif;
      font-size:   13px;
      line-height: 18px;
    }

    pre {
      background-color: #eee;
      padding: 10px;
      font-size: 11px;
    }

    a { color: #000; }
    a:visited { color: #666; }
    a:hover { color: #fff; background-color:#000; }
  </style>
</head>
<body>

<h1>
  LoadError
    in MyappsController#show
</h1>
<pre>no such file to load -- /home/xanview2/blankapp/app/controllers/myapps_controller.rb</pre>


<p><code>Rails.root: /home/xanview2/blankapp</code></p>

<div id="traces">
    <a href="#" onclick="document.getElementById('Framework-Trace').style.display='none';document.getElementById('Full-Trace').style.display='none';document.getElementById('Application-Trace').style.display='block';; return false;">Application Trace</a> |
    <a href="#" onclick="document.getElementById('Application-Trace').style.display='none';document.getElementById('Full-Trace').style.display='none';document.getElementById('Framework-Trace').style.display='block';; return false;">Framework Trace</a> |
    <a href="#" onclick="document.getElementById('Application-Trace').style.display='none';document.getElementById('Framework-Trace').style.display='none';document.getElementById('Full-Trace').style.display='block';; return false;">Full Trace</a> 

    <div id="Application-Trace" style="display: block;">
      <pre><code></code></pre>
    </div>
    <div id="Framework-Trace" style="display: none;">
      <pre><code>activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:452:in `load'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:452:in `block in load_file'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:639:in `new_constants_in'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:451:in `load_file'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:338:in `require_or_load'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:489:in `load_missing_constant'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:181:in `block in const_missing'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:179:in `each'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:179:in `const_missing'
activesupport (3.1.0.rc1) lib/active_support/inflector/methods.rb:124:in `block in constantize'
activesupport (3.1.0.rc1) lib/active_support/inflector/methods.rb:123:in `each'
activesupport (3.1.0.rc1) lib/active_support/inflector/methods.rb:123:in `constantize'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:527:in `block in initialize'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:549:in `yield'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:549:in `default'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:549:in `[]'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:61:in `controller_reference'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:46:in `controller'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:25:in `call'
rack-mount (0.8.1) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:89:in `optimized_each'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.8.1) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:531:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.0) lib/rack/etag.rb:23:in `call'
rack (1.3.0) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/flash.rb:243:in `call'
rack (1.3.0) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.0) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/cookies.rb:321:in `call'
activerecord (3.1.0.rc1) lib/active_record/query_cache.rb:54:in `call'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.0) lib/rack/sendfile.rb:102:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.0.rc1) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.0) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.0) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.0.rc1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.0) lib/rack/lock.rb:34:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.0.rc1) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.0.rc1) lib/rails/engine.rb:438:in `call'
railties (3.1.0.rc1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.0) lib/rack/handler/webrick.rb:59:in `service'
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'</code></pre>
    </div>
    <div id="Full-Trace" style="display: none;">
      <pre><code>activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:452:in `load'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:452:in `block in load_file'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:639:in `new_constants_in'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:451:in `load_file'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:338:in `require_or_load'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:489:in `load_missing_constant'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:181:in `block in const_missing'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:179:in `each'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:179:in `const_missing'
activesupport (3.1.0.rc1) lib/active_support/inflector/methods.rb:124:in `block in constantize'
activesupport (3.1.0.rc1) lib/active_support/inflector/methods.rb:123:in `each'
activesupport (3.1.0.rc1) lib/active_support/inflector/methods.rb:123:in `constantize'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:527:in `block in initialize'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:549:in `yield'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:549:in `default'
activesupport (3.1.0.rc1) lib/active_support/dependencies.rb:549:in `[]'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:61:in `controller_reference'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:46:in `controller'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:25:in `call'
rack-mount (0.8.1) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:89:in `optimized_each'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.8.1) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:531:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.0) lib/rack/etag.rb:23:in `call'
rack (1.3.0) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/flash.rb:243:in `call'
rack (1.3.0) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.0) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/cookies.rb:321:in `call'
activerecord (3.1.0.rc1) lib/active_record/query_cache.rb:54:in `call'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.0) lib/rack/sendfile.rb:102:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.0.rc1) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.0) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.0) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.0.rc1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.0) lib/rack/lock.rb:34:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.0.rc1) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.0.rc1) lib/rails/engine.rb:438:in `call'
railties (3.1.0.rc1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.0) lib/rack/handler/webrick.rb:59:in `service'
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'</code></pre>
    </div>
</div>



<h2 style="margin-top: 30px">Request</h2>
<p><b>Parameters</b>: <pre>{&quot;id&quot;=&gt;&quot;1&quot;}</pre></p>

<p><a href="#" onclick="document.getElementById('session_dump').style.display='block'; return false;">Show session dump</a></p>
<div id="session_dump" style="display:none"><pre></pre></div>

<p><a href="#" onclick="document.getElementById('env_dump').style.display='block'; return false;">Show env dump</a></p>
<div id="env_dump" style="display:none"><pre>GATEWAY_INTERFACE: &quot;CGI/1.1&quot;
HTTP_ACCEPT: &quot;*/*&quot;
REMOTE_ADDR: &quot;192.168.0.7&quot;
REMOTE_HOST: &quot;192.168.0.7&quot;
SERVER_NAME: &quot;192.168.0.7&quot;
SERVER_PROTOCOL: &quot;HTTP/1.1&quot;</pre></div>


<h2 style="margin-top: 30px">Response</h2>
<p><b>Headers</b>: <pre>None</pre></p>



</body>
</html>

Any ideas?

@xanview
xanview commented May 25, 2011

Doesn't happen on 3.0.7

@xanview
xanview commented May 25, 2011

Also, this doesn't happen on 3.1rc1 running in the production environment

@joeljunstrom

Can reproduce on mac os X

@yyyc514
yyyc514 commented May 25, 2011

Reproducible on OS X / 3.1RC1 / REE 187... interestingly enough if you change Myapp.find(params[:id]) to Myapp.first it runs quite a while with no issue... and I can't reproduce the memory issue... my memory is steady but after 250 requests it blows up with the error it can't load the controller file.

Some issue with perhaps running out of file handles?

@xanview
xanview commented May 25, 2011

Interesting, if switching to mysql from sqlite3 - I'm no longer able to reproduce the issue! - It seems like an sqlite issue!

@tenderlove tenderlove was assigned May 25, 2011
@iHiD
iHiD commented May 26, 2011

I'm running this in development on mysql and leaking like crazy too. I'm running out of memory (and having to force kill) before capping out so I haven't yet been able to get a stack trace.

@gnufied
gnufied commented May 27, 2011

Yup this is consistently reproducible. I am taking a stab at it. :)

@gnufied gnufied pushed a commit to gnufied/rails that referenced this issue May 27, 2011
@tenderlove tenderlove work around bug in the sqlite3 bindings. fixes #1289 985ace4
@jake3030 jake3030 pushed a commit to jake3030/rails that referenced this issue Jun 28, 2011
@bernardo bernardo Fix regression bug that made date_select and datetime_select raise a …
…Null Pointer Exception when a nil date/datetime was passed and only month and year were displayed [#1289 state:committed]

Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
b2cd318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.