I am getting this error - `psycopg2.OperationalErr...
# plugins-general
i
I am getting this error -
psycopg2.OperationalError: SSL SYSCALL error: EOF detected
While transferring data from tap-postgres to target-postgres. The table has about 32 Lac rows.
Copy code
meltano     | Running extract & load...
meltano     | No state was found, complete import.
target-postgres | INFO PostgresTarget created with established connection: `user=xxx password=xxx dbname=xxx host=xxx port=xxx sslmode=prefer sslcert=~/.postgresql/postgresql.crt sslkey=~/.postgresql/postgresql.key sslrootcert=~/.postgresql/root.crt sslcrl=~/.postgresql/root.crl`, PostgreSQL schema: `xxx_schema`
tap-postgres  | time=2021-01-05 19:16:58 name=tap_postgres level=INFO message=Selected streams: [] 
target-postgres | INFO Sending version information to <http://singer.io|singer.io>. To disable sending anonymous usage data, set the config parameter "disable_collection" to true
tap-postgres  | time=2021-01-05 19:25:57 name=tap_postgres level=INFO message=No streams marked as currently_syncing in state file
target-postgres | Traceback (most recent call last):
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/bin/target-postgres", line 8, in <module>
target-postgres |   sys.exit(cli())
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/lib/python3.6/site-packages/target_postgres/__init__.py", line 45, in cli
target-postgres |   main(args.config)
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/lib/python3.6/site-packages/target_postgres/__init__.py", line 39, in main
target-postgres |   target_tools.main(postgres_target)
target-postgres | psycopg2.OperationalError: SSL SYSCALL error: EOF detected
target-postgres | 
meltano     | Loading failed (1): (see above)
meltano     | ELT could not be completed: Target failed
Can anyone please help?
When I set
logging_level: DEBUG
Copy code
meltano     | Running extract & load...
meltano     | No state was found, complete import.
target-postgres | INFO PostgresTarget created with established connection: `user=xxx password=xxx dbname=xxx host=xxx port=xxx sslmode=prefer sslcert=~/.postgresql/postgresql.crt sslkey=~/.postgresql/postgresql.key sslrootcert=~/.postgresql/root.crt sslcrl=~/.postgresql/root.crl`, PostgreSQL schema: `xxx_schema`
target-postgres | DEBUG PostgresTarget set to log all queries.
tap-postgres  | time=2021-01-06 03:04:32 name=tap_postgres level=INFO message=Selected streams: [] 
target-postgres | DEBUG MillisLoggingConnection: 456 millis spent executing: b"\n      SELECT c.relname, obj_description(c.oid, 'pg_class')\n      FROM pg_namespace AS n\n        INNER JOIN pg_class AS c ON n.oid = c.relnamespace\n      WHERE n.nspname = 'xxx_schema';\n    "
target-postgres | DEBUG MillisLoggingConnection: 227 millis spent executing: b"\n      SELECT c.relname, obj_description(c.oid, 'pg_class')\n      FROM pg_namespace AS n\n        INNER JOIN pg_class AS c ON n.oid = c.relnamespace\n      WHERE n.nspname = 'xxx_schema';\n    "
target-postgres | INFO Sending version information to <http://singer.io|singer.io>. To disable sending anonymous usage data, set the config parameter "disable_collection" to true
target-postgres | DEBUG Collection request failed
tap-postgres  | time=2021-01-06 03:12:03 name=tap_postgres level=INFO message=No streams marked as currently_syncing in state file
target-postgres | Traceback (most recent call last):
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/bin/target-postgres", line 8, in <module>
target-postgres |   sys.exit(cli())
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/lib/python3.6/site-packages/target_postgres/__init__.py", line 45, in cli
target-postgres |   main(args.config)
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/lib/python3.6/site-packages/target_postgres/__init__.py", line 39, in main
target-postgres |   target_tools.main(postgres_target)
target-postgres | psycopg2.OperationalError: SSL SYSCALL error: EOF detected
target-postgres | 
meltano     | Loading failed (1): (see above)
meltano     | ELT could not be completed: Target failed
ELT could not be completed: Target failed
z
Do you have data flowing in from your tap?
i
No
When I set configurations in
meltano.yml
, the process gets stuck at this step for quite long time
meltano     | No state was found, complete import.
and then gets failed. In 1 out of 10 it gets succeeed
when I use env variables then it works all the time
d
I am getting this error - 
psycopg2.OperationalError: SSL SYSCALL error: EOF detected
While transferring data from tap-postgres to target-postgres.
@irfan_alam https://github.com/psycopg/psycopg2/issues/533 suggests that this means that the database is closing the connection prematurely, possibly because of an out-of-memory issue. Is that possible?
When I set configurations in 
meltano.yml
, the process gets stuck at this step for quite long time 
meltano     | No state was found, complete import.
 and then gets failed. In 1 out of 10 it gets succeeed
when I use env variables then it works all the time
@irfan_alam Do you see a difference in the output for
meltano config target-postgres
when you use
meltano.yml
vs environment variables?
i
Well most of the time it failed when configurations was in meltano.yml, but I think when it succeeded 1 time then there were no difference in output
d
@irfan_alam OK, then I think it's not related to where the config is stored, since Meltano should pass it to the plugin the same way anyway. It's more likely to have been a coincidence, with the real issue having to do with database memory/resource usage.
i
This happened with I used tap-postgres
psycopg2.OperationalError: SSL SYSCALL error: EOF detected
target-postgres | CRITICAL cursor already closed
Parts of the log
Copy code
tap-freshdesk  | INFO Completed sync
target-postgres | DEBUG MillisLoggingConnection: 0 millis spent executing: b'BEGIN;'
target-postgres | DEBUG MillisLoggingConnection: 0 millis spent executing: b'BEGIN;'
target-postgres | CRITICAL cursor already closed
target-postgres | Traceback (most recent call last):
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/lib/python3.7/site-packages/target_postgres/postgres.py", line 234, in write_batch
target-postgres |   cur.execute('BEGIN;')
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/lib/python3.7/site-packages/target_postgres/postgres.py", line 65, in execute
target-postgres |   return super(_MillisLoggingCursor, self).execute(query, vars)
target-postgres |  File "/project/.meltano/loaders/target-postgres/venv/lib/python3.7/site-packages/psycopg2/extras.py", line 461, in execute
target-postgres |   return super(LoggingCursor, self).execute(query, vars)
target-postgres | psycopg2.OperationalError: SSL SYSCALL error: EOF detected
d
@irfan_alam It looks your Postgres DB is closing the connection for some reason (possibly because it's running out of memory or other resources), and target-postgres is not handling the error and attempting to reconnect. Do you have any idea why the connection may be getting dropped? You may want to try one of the other target-postgres variants: https://meltano.com/plugins/loaders/postgres.html#alternative-variants One of them may handle dropped connections better.
i
The tap-freshdesk takes too much time to fetch data, I think more than 20-30 minutes. By the time the Postgres connection will be closed anyhow. Why do you establish a connection beforehand when extracting data? Why don't after tap data are extracted?
d
@irfan_alam Is the tap waiting for all the data to be extracted before it starts sending records to the target? The tap and target run in a parallel and the tap's stdout output is piped into the target's stdin, so the target shouldn't need to wait until all data is extracted, and typically starts inserting new records just a few seconds after it makes the connection to the DB, when the tap outputs its first record message. If the target is sitting idle for 20-30 minutes and letting the connection expire, the tap may be misbehaving.
tap-freshdesk immediately writes record messages when it gets them from the API: https://github.com/singer-io/tap-freshdesk/blob/master/tap_freshdesk/__init__.py#L162, so the target should be able to start processing them immediately.
Based on that, it doesn't look to me like the connection is established and then sits there unused for a while until it expires and gets disconnected.
If you run the ELT pipeline in debug mode (https://meltano.com/docs/command-line-interface.html#debugging), do you see messages passed from the tap to the target continuously, or is there a large amount of time where the tap isn't sending anything?
Either way, target-Postgres could be handling the disconnection better by attempting to reconnect. Another variant (https://meltano.slack.com/archives/C013EKWA2Q1/p1610123961021700?thread_ts=1609901332.013400&amp;channel=C013EKWA2Q1&amp;message_ts=1610123961.021700) may do that already, or you can consider contributing a fix to the variant you’re currently using