我想知道如何防止这种类型的错误。到目前为止,我尝试通过AWS Opsworks上的数据库配置禁用预准备语句:
例如:
数据库配置
},
"deploy": {
"app_name": {
"database": {
"adapter": "postgresql",
"prepared_statements": false,
"username": "username",
"database": "db_name_production",
"host": "cool_host.com",
"password": "easy"
},
错误记录
PG::DuplicatePstatement: ERROR: prepared statement "a6" already exists : INSERT INTO "polls" ("answer_type", "auto_enable", "can_have_correct_answer", "created_at", "de", "en", "es", "event_id", "game_card_length", "game_card_start", "id_language_code", "is_custom_question", "ja", "language_id", "points_award", "poll_upload_id", "pop_up_length", "pop_up_start", "pop_up_trigger_type", "pt", "question", "question_identifier", "question_tag", "question_translation", "question_type", "scorecard_presentation", "show_at_minute", "show_n_seconds", "template_type", "th", "trigger_restriction", "updated_at", "vi", "vizrt_show_name", "vizrt_template_name", "vote_options", "vote_options_translation") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37) RETURNING "id"
URL: http://app.domain.com/admin/polls
BACKTRACE:
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `prepare'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `prepare_statement'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:1168:in `exec_cache'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `block in exec_query'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/instrumentation/active_record.rb:46:in `block in log_with_newrelic_instrumentation'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/method_tracer.rb:235:in `trace_execution_scoped'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/instrumentation/active_record.rb:43:in `log_with_newrelic_instrumentation'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `exec_query'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/relation.rb:66:in `insert'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/persistence.rb:367:in `create'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/timestamp.rb:58:in `create'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/callbacks.rb:268:in `block in create'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:403:in `_run__355353764622945659__create__4467585814663071278__callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/callbacks.rb:268:in `create'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/persistence.rb:348:in `create_or_update'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/callbacks.rb:264:in `block in create_or_update'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:447:in `_run__355353764622945659__save__4467585814663071278__callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/callbacks.rb:264:in `create_or_update'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/persistence.rb:84:in `save'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/validations.rb:50:in `save'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/attribute_methods/dirty.rb:22:in `save'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/transactions.rb:208:in `transaction'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/method_tracer.rb:497:in `block in transaction_with_trace_ActiveRecord_self_name_transaction'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/method_tracer.rb:235:in `trace_execution_scoped'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/method_tracer.rb:493:in `transaction_with_trace_ActiveRecord_self_name_transaction'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/transactions.rb:259:in `block in save'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/transactions.rb:258:in `save'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bundler/gems/active_admin-b41450a52c09/lib/active_admin/resource_controller/data_access.rb:163:in `block in save_resource'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bundler/gems/active_admin-b41450a52c09/lib/active_admin/callbacks.rb:78:in `run_save_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bundler/gems/active_admin-b41450a52c09/lib/active_admin/resource_controller/data_access.rb:162:in `save_resource'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bundler/gems/active_admin-b41450a52c09/lib/active_admin/resource_controller/data_access.rb:152:in `block in create_resource'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bundler/gems/active_admin-b41450a52c09/lib/active_admin/callbacks.rb:78:in `run_create_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bundler/gems/active_admin-b41450a52c09/lib/active_admin/resource_controller/data_access.rb:151:in `create_resource'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/inherited_resources-1.4.1/lib/inherited_resources/actions.rb:33:in `create'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bundler/gems/active_admin-b41450a52c09/lib/active_admin/resource_controller/actions.rb:48:in `create'
/srv/www/app_pro/releases/20140930174854/app/admin/polls.rb:13:in `create'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/abstract_controller/base.rb:167:in `process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal/rendering.rb:10:in `process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:480:in `_run__674118340747155841__process_action__4403365755486731848__callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal/rescue.rb:29:in `process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/notifications.rb:123:in `block in instrument'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/notifications.rb:123:in `instrument'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:38:in `block in process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:357:in `perform_action_with_newrelic_trace'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:37:in `process_action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/abstract_controller/base.rb:121:in `process'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/abstract_controller/rendering.rb:45:in `process'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal.rb:203:in `dispatch'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_controller/metal.rb:246:in `block in action'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/routing/route_set.rb:73:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/routing/route_set.rb:36:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/routing/route_set.rb:608:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/omniauth-1.2.1/lib/omniauth/builder.rb:59:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/rack/error_collector.rb:55:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/rack/agent_hooks.rb:32:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/newrelic_rpm-3.8.1.221/lib/new_relic/rack/browser_monitoring.rb:27:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-1.4.5/lib/rack/deflater.rb:13:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/head.rb:14:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/flash.rb:242:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/query_cache.rb:64:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `_run__1037584046338014875__call__4467585814663071278__callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/railties-3.2.19/lib/rails/rack/logger.rb:32:in `call_app'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/railties-3.2.19/lib/rails/rack/logger.rb:16:in `block in call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/tagged_logging.rb:22:in `tagged'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/railties-3.2.19/lib/rails/rack/logger.rb:16:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/activesupport-3.2.19/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/actionpack-3.2.19/lib/action_dispatch/middleware/static.rb:63:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-timeout-0.0.4/lib/rack/timeout.rb:16:in `block in call'
/usr/local/lib/ruby/1.9.1/timeout.rb:69:in `timeout'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/rack-timeout-0.0.4/lib/rack/timeout.rb:16:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/railties-3.2.19/lib/rails/engine.rb:484:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/railties-3.2.19/lib/rails/application.rb:231:in `call'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/railties-3.2.19/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:in `process_client'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start'
/home/deploy/.bundler/app_pro/ruby/1.9.1/gems/unicorn-4.8.3/bin/unicorn_rails:209:in `'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bin/unicorn_rails:23:in `load'
/home/deploy/.bundler/app_pro/ruby/1.9.1/bin/unicorn_rails:23:in `'
提前致谢。
答案 0 :(得分:3)
我在rails 4.2上遇到了同样的问题
对于Rails> 4.1
1)添加heroku的PG保镖buildpack
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-pgbouncer
2)在heroku环境变量中将PGBOUNCER_PREPARED_STATEMENTS
添加到false
。
还有另一种解决方案
Another option is to use `Thread.handle_interrupt` to prevent exceptions from being raised inside critical sections
答案 1 :(得分:1)
您是否正在使用Rack :: Timeout?如果意外引发了超时异常,则可能会丢失状态。 (https://github.com/heroku/rack-timeout/blob/master/doc/risks.md)。
准备好的语句号的增加可能会陷入循环中,从而导致重复语句错误,并且必须重新启动进程才能恢复。建议实施https://github.com/ankane/slowpoke,以在发生超时时终止/重新启动该进程。
了解有关此问题的更多信息:
答案 2 :(得分:-2)
<强>解决方案强>
使用以下代码添加初始化程序:
# gist: https://gist.github.com/catsby/0b676949b6cd414357df
# source https://github.com/gregburek/heroku-buildpack-pgbouncer#disable-prepared-statements
require "active_record/connection_adapters/postgresql_adapter"
class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
alias initialize_without_config_boolean_coercion initialize
def initialize(connection, logger, connection_parameters, config)
config = config.merge(prepared_statements: false)
initialize_without_config_boolean_coercion(connection, logger, connection_parameters, config)
end
end