Problem with Mephisto blog and Passenger

I seem to be getting a SystemStackError exception when running
Mephisto under Passenger. The trace I get has 149 lines of backtrace,
which seems large, but when looking at it I don't see any loops nor
other issues. I think this may actually be hitting a system limit.

So, the question is, how do I work around this? Can the stack size be
increased using some Passenger knob I was thus far unable to discover,
or is this a compile-time option I need to tweak?

Thanks,
--Michael

M Graff wrote:

I seem to be getting a SystemStackError exception when running
Mephisto under Passenger. The trace I get has 149 lines of backtrace,
which seems large, but when looking at it I don't see any loops nor
other issues. I think this may actually be hitting a system limit.

So, the question is, how do I work around this? Can the stack size be
increased using some Passenger knob I was thus far unable to discover,
or is this a compile-time option I need to tweak?

Before tweaking Passenger, make sure everything else is OK. Perhaps put
the trace on Pastie or something so we can see it?

Thanks,
--Michael

Best,

Michael,

I have been using Mephisto with Passenger and its working great.Try
providing the stack trace.

Thanks,
Kilari.

OK, sorry for the spam here :slight_smile:

This is when attempting to post a new article, but it also happens in
liquid templates from time to time.

Posting comments works, logging in does as well. This is using a
slightly themed but otherwise stock template in terms of what is in
the template files.

SystemStackError (stack level too deep):
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:121:in
`retrieve_connection'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:113:in
`connection'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2237:in
`quote_bound_value'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2197:in
`replace_bind_variables'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2197:in
`gsub'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2197:in
`replace_bind_variables'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2186:in
`sanitize_sql_array'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2079:in
`sanitize_sql'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1441:in
`merge_conditions'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1439:in
`each'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1439:in
`merge_conditions'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1742:in
`add_conditions!'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/calculations.rb:200:in
`construct_calculation_sql'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/calculations.rb:225:in
`execute_simple_calculation'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/calculations.rb:126:in
`calculate'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/calculations.rb:122:in
`catch'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/calculations.rb:122:in
`calculate'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/calculations.rb:48:in
`count'
    /app/models/assigned_section.rb:10:in `check_for_dupe_article_and_section'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in
`evaluate_method'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:166:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in
`run'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in
`each'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in
`run'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:277:in
`run_callbacks'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/validations.rb:1033:in
`valid_without_callbacks?'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:286:in
`valid?'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/validations.rb:1008:in
`save_without_dirty'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/dirty.rb:79:in
`save_without_transactions'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:179:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:179:in
`with_transaction_returning_status'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:550:in
`transaction'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:129:in
`transaction'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:138:in
`transaction'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:178:in
`with_transaction_returning_status'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:146:in
`save'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:158:in
`rollback_active_record_state!'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:146:in
`save'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:237:in
`create'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:405:in
`create_record'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:423:in
`add_record_to_target_with_callbacks'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:405:in
`create_record'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:235:in
`create'
    /app/models/article.rb:214:in `save_assigned_sections'
    /app/models/article.rb:214:in `each'
    /app/models/article.rb:214:in `save_assigned_sections'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in
`evaluate_method'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:166:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:93:in
`run'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in
`each'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:92:in
`run'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:277:in
`run_callbacks'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:315:in
`callback'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:223:in
`create_or_update'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2383:in
`save_without_validation'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/validations.rb:1009:in
`save_without_dirty'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/dirty.rb:79:in
`save_without_transactions'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:179:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:179:in
`with_transaction_returning_status'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:550:in
`transaction'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:129:in
`transaction'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:138:in
`transaction'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:178:in
`with_transaction_returning_status'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:146:in
`save'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:158:in
`rollback_active_record_state!'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:146:in
`save'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:237:in
`create'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:405:in
`create_record'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:423:in
`add_record_to_target_with_callbacks'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:405:in
`create_record'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb:235:in
`create'
    /app/controllers/admin/articles_controller.rb:44:in `create'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
`call_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:638:in
`run_before_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:206:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:206:in
`around_proc'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:182:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:182:in
`evaluate_method'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:184:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:635:in
`run_before_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:615:in
`call_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:638:in
`run_before_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:206:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:206:in
`around_proc'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:182:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:182:in
`evaluate_method'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:184:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:635:in
`run_before_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:615:in
`call_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:638:in
`run_before_filters'
    /app/controllers/application.rb:111:in `get_requests_are_readonly'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in
`evaluate_method'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:186:in
`call'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:635:in
`run_before_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:615:in
`call_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
    /usr/pkg/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in
`perform_action_without_caching'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in
`passenger_orig_perform_action'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
`cache'
    /usr/pkg/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in
`cache'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in
`passenger_orig_perform_action'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/request_handler.rb:64:in
`perform_action'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`send'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`process_without_filters'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in
`process_without_session_management_support'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in
`process'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:in
`process'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in
`handle_request'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in
`dispatch_unlocked'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in
`dispatch'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in
`synchronize'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in
`dispatch'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in
`dispatch_cgi'
    /usr/pkg/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in
`dispatch'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/request_handler.rb:49:in
`process_request'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_request_handler.rb:206:in
`main_loop'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/application_spawner.rb:376:in
`start_request_handler'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/application_spawner.rb:334:in
`handle_spawn_application'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/utils.rb:182:in
`safe_fork'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/application_spawner.rb:332:in
`handle_spawn_application'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:351:in
`__send__'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:351:in
`main_loop'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:195:in
`start_synchronously'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:162:in
`start'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/railz/application_spawner.rb:213:in
`start'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:261:in
`spawn_rails_application'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server_collection.rb:126:in
`lookup_or_add'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:255:in
`spawn_rails_application'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server_collection.rb:80:in
`synchronize'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server_collection.rb:79:in
`synchronize'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:254:in
`spawn_rails_application'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:153:in
`spawn_application'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/spawn_manager.rb:286:in
`handle_spawn_application'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:351:in
`__send__'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:351:in
`main_loop'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/lib/phusion_passenger/abstract_server.rb:195:in
`start_synchronously'
    /usr/pkg/lib/ruby/gems/1.8/gems/passenger-2.2.4/bin/passenger-spawn-server:61