PG::DupliacatePstatement: Error: prepared statement already exists

I am getting the following error in production environment

"PG::DupliacatePstatement: Error: prepared statement already exists"

Ruby version is 2.2.4 and
Rails version is 4.1.3

I have the following code in my unicorn.rb file:

    before_fork do |server, worker|
    Signal.trap 'TERM' do
      puts 'Unicorn master intercepting TERM and sending myself QUIT
      Process.kill 'QUIT',

    defined?(ActiveRecord::Base) and

    after_fork do |server, worker|
      Signal.trap 'TERM' do
        puts 'Unicorn worker intercepting TERM and doing nothing. Wait
for master to send QUIT'

    defined?(ActiveRecord::Base) and

I have added

    prepared_statement: false

in database.yml file. In environments/production.rb file, I have

    config.cache_classes = false
    config.action_controller.perform_caching = false

Can anyone please suggest a solution for this error?



Show us the lines of code that cause the problem.