如何修复PG :: DuplicatePstatement:ERROR?

时间:2022-11-07 19:12:21

I would like to know how to prevent this type of error. So far I tried disabling prepared statements via the database configuration at AWS Opsworks:

我想知道如何防止这种类型的错误。到目前为止,我尝试通过AWS Opsworks上的数据库配置禁用预准备语句:

Eg:

例如:

Database Configuration

数据库配置

},
"deploy": {
    "app_name": {
        "database": {
            "adapter": "postgresql",
            "prepared_statements": false,
            "username": "username",
            "database": "db_name_production",
            "host": "cool_host.com",
            "password": "easy"
        },

Error Log

错误日志

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 `'

Thanks in advance.

提前致谢。

2 个解决方案

#1


2  

I got the same issue on rails 4.2 fixed it by

我在rails 4.2上得到了同样的问题

For Rails > 4.1

对于Rails> 4.1

1) Add PG bouncer buildpack of heroku

1)添加heroku的PG保镖buildpack

heroku buildpacks:add https://github.com/heroku/heroku-buildpack-pgbouncer

2) Add PGBOUNCER_PREPARED_STATEMENTS to false in heroku environment variable.

2)在heroku环境变量中将PGBOUNCER_PREPARED_STATEMENTS添加到false。

there are another solution is

还有另一种解决方案

Another option is to use `Thread.handle_interrupt` to prevent exceptions from being raised inside critical sections 

#2


-2  

Solution

Add an initializer with the following code:

使用以下代码添加初始化程序:

# 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

#1


2  

I got the same issue on rails 4.2 fixed it by

我在rails 4.2上得到了同样的问题

For Rails > 4.1

对于Rails> 4.1

1) Add PG bouncer buildpack of heroku

1)添加heroku的PG保镖buildpack

heroku buildpacks:add https://github.com/heroku/heroku-buildpack-pgbouncer

2) Add PGBOUNCER_PREPARED_STATEMENTS to false in heroku environment variable.

2)在heroku环境变量中将PGBOUNCER_PREPARED_STATEMENTS添加到false。

there are another solution is

还有另一种解决方案

Another option is to use `Thread.handle_interrupt` to prevent exceptions from being raised inside critical sections 

#2


-2  

Solution

Add an initializer with the following code:

使用以下代码添加初始化程序:

# 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