Skip to content

PG::ConnectionBad: PQsocket() can't get socket descriptor: ROLLBACK #64

@ajparise

Description

@ajparise

Our app opens a cursor which can run for hours at a time.
On the longer runs (7+ hours) the cursor occasionally errors out with:

ActiveRecord::StatementInvalid
PG::ConnectionBad: PQsocket() can't get socket descriptor: ROLLBACK

I am trying to rule this gem out as the culprit. I'm not sure if this is masking a different error.
Should we be passing with_hold: true in the options?

Here is a snippet of the cursor loop:

# BATCH_SIZE = 10_000
 records.each_instance(block_size: BATCH_SIZE) { |record| @handler.call(record) }

Couple things that may or may not be pertinent:

  • We tried upgrading to 0.6.7 and see the same behavior
  • The records returned by the cursor have associations on them.
  • App makes other read only ActiveRecord calls within the block passed to #each_instance
    • these read only calls do not access the same table as the cursor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions