Skip to content

Instantly share code, notes, and snippets.

View nicksieger's full-sized avatar

Nick Sieger nicksieger

View GitHub Profile
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index bdae5f9..a6bac65 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -20,8 +20,10 @@ module ActionController
end
if defined?(ActiveRecord)
- before_dispatch { ActiveRecord::Base.verify_active_connections! }
to_prepare(:activerecord_instantiate_observers) { ActiveRecord::Base.instantiate_observers }
require File.dirname(__FILE__) + '/bench_model'
puts "Widget.find(:all)"
Benchmark.bm do |make|
TIMES.times do
make.report do
10_000.times do
Widget.find(:all)
end
end
$ ab -n 1000 -c 4 http://localhost:8080/sillytestapp/greetings
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
/*
* Copyright 2007-2008 Sun Microsystems, Inc.
* This source code is available under the MIT license.
* See the file LICENSE.txt for details.
*/
package org.jruby.rack;
import java.io.IOException;
import javax.servlet.ServletConfig;
Database connections are now pooled, one pool per #establish_connection call.
Pools start out empty and grow as necessary to a maximum size (default is 5,
configure size with key 'pool' in your database configuration). If no
connections are available, a thread will wait up to a 'wait_timeout' time
(default is 5 seconds).
Connections are verified and reset when checked out from the pool (usually
upon first access to ActiveRecord::Base.connection), and returned back to the
pool after each request.
java.lang.StackOverflowError
at org.jruby.java.proxies.JavaInterfaceTemplate.appendFeaturesToClass(JavaInterfaceTemplate.java:85)
at org.jruby.java.proxies.JavaInterfaceTemplate.append_features(JavaInterfaceTemplate.java:73)
at org.jruby.java.proxies.JavaInterfaceTemplate$s_method_1_0$RUBYFRAMEDINVOKER$append_features.call(org/jruby/java/proxies/JavaInterfaceTemplate$s_method_1_0$RUBYFRAMEDINVOKER$append_features.gen)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneBlock.call(JavaMethod.java:580)
at org.jruby.RubyClass.invoke(RubyClass.java:333)
...
at org.jruby.javasupport.util.RuntimeHelpers.invokeAs(RuntimeHelpers.java:366)
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 838b043..c7f04de 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -201,7 +201,7 @@ module ActiveRecord
def checkout_and_verify(c)
c.run_callbacks :checkout
- c.verify!(verification_timeout)
+ c.verify_now!
From 662a9ed4286e1cf3118ad333955e16ab761cd350 Mon Sep 17 00:00:00 2001
From: Nick Sieger <nick@nicksieger.com>
Date: Thu, 4 Sep 2008 14:03:19 +0200
Subject: [PATCH] Deprecate verification_timeout and verify before reset
---
.../abstract/connection_pool.rb | 6 ++----
.../abstract/connection_specification.rb | 15 ++++++++++-----
.../connection_adapters/abstract_adapter.rb | 12 ++++--------
activerecord/test/cases/base_test.rb | 2 +-
From 668d43b053f5f651b66357b3599e4bdec2c4a9e3 Mon Sep 17 00:00:00 2001
From: Nick Sieger <nick@nicksieger.com>
Date: Thu, 4 Sep 2008 15:16:29 +0200
Subject: [PATCH] Default connection allow_concurrency to false (for PostgreSQL)
---
.../abstract/connection_pool.rb | 3 +--
activerecord/lib/active_record/test_case.rb | 15 +++++++++++++++
activerecord/test/cases/locking_test.rb | 2 ++
activerecord/test/cases/transactions_test.rb | 2 ++
From c5d18f6308d6980238caee2aea97df7894de4533 Mon Sep 17 00:00:00 2001
From: Nick Sieger <nick@nicksieger.com>
Date: Thu, 4 Sep 2008 15:35:55 +0200
Subject: [PATCH] Remove flawed execute("ROLLBACK") approach; #reset! defaults to nothing
Will need community help to fill out what #reset! should do for each adapter
---
.../connection_adapters/abstract_adapter.rb | 4 +---
.../connection_adapters/mysql_adapter.rb | 2 --
2 files changed, 1 insertions(+), 5 deletions(-)