Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid connection! (PG::Error) #16

Open
ashawley opened this issue May 21, 2016 · 2 comments
Open

Invalid connection! (PG::Error) #16

ashawley opened this issue May 21, 2016 · 2 comments
Labels

Comments

@ashawley
Copy link
Contributor

I get the error Invalid connection! (PG::Error) from the Postgres source database with a large table that is about 33GB. After about 40 minutes, it gives the following error:

$ postgres_to_redshift
INFO:  Relation "submissions" already exists and will be skipped
Downloading submissions
Uploading submissions.1
Uploading submissions.2
Uploading submissions.3
Uploading submissions.4
Uploading submissions.5
Uploading submissions.6
Uploading submissions.7
Uploading submissions.8
Uploading submissions.9
/usr/local/share/ruby/gems/2.2/gems/pg-0.17.1/lib/pg/connection.rb:140:in `cancel': Invalid connection! (PG::Error)
        from /usr/local/share/ruby/gems/2.2/gems/pg-0.17.1/lib/pg/connection.rb:140:in `rescue in copy_data'
        from /usr/local/share/ruby/gems/2.2/gems/pg-0.17.1/lib/pg/connection.rb:137:in `copy_data'
        from ~/.gem/ruby/2.2/gems/postgres_to_redshift-0.1.1/lib/postgres_to_redshift.rb:97:in `copy_table'
        from ~/.gem/ruby/2.2/gems/postgres_to_redshift-0.1.1/lib/postgres_to_redshift.rb:27:in `block in update_tables'
        from ~/.gem/ruby/2.2/gems/postgres_to_redshift-0.1.1/lib/postgres_to_redshift.rb:24:in `each'
        from ~/.gem/ruby/2.2/gems/postgres_to_redshift-0.1.1/lib/postgres_to_redshift.rb:24:in `update_tables'
        from ~/.gem/ruby/2.2/gems/postgres_to_redshift-0.1.1/bin/postgres_to_redshift:5:in `<top (required)>'
        from ~/bin/postgres_to_redshift:23:in `load'
        from ~/bin/postgres_to_redshift:23:in `<main>'

This happens for a 16GB table, as well.

NOTE: That I am using the code from #15 to split files up and the code from #14 to avoid out-of memory.

Is the database connection getting lost? I've modified the following settings on the Postgres 9.3 RDS instance at AWS:

tcp_keepalives_count      10
tcp_keepalives_idle     1200
tcp_keepalives_interval 1200

Seems like it should allow 20 minutes of idle and check up to 10 times, but error keeps happening.

@toothrot
Copy link
Owner

Hey @ashawley,

It looks like those parameters are ignored on Unix sockets, so I'm not sure if they help: https://www.postgresql.org/docs/9.5/static/runtime-config-connection.html

I was going to add some connection pooling and retry logic. PG connections are cheap to open, so we could just open a fresh one for every query, tbh.

@toothrot toothrot added the ready label May 25, 2016
@ashawley
Copy link
Contributor Author

ashawley commented May 25, 2016

I actually tried reopening fresh connections in b4848f8. Unfortunately the same error kept happening. Although, the script did seem to get further along...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants