Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
PG12 per session wal_sender_timeout (#42)
Browse files Browse the repository at this point in the history
* Support per session wal_sender_timout for PG12 and above
* bump version
  • Loading branch information
louis-pie authored Mar 9, 2020
1 parent 486ebd6 commit ecf04e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description = f.read()

setup(name='pipelinewise-tap-postgres',
version='1.4.1',
version='1.5.0',
description='Singer.io tap for extracting data from PostgresSQL - PipelineWise compatible',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
18 changes: 18 additions & 0 deletions tap_postgres/sync_strategies/logical_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,24 @@ def sync_tables(conn_info, logical_streams, state, end_lsn, state_file):
conn = post_db.open_connection(conn_info, True)
cur = conn.cursor()

# Set session wal_sender_timeout for PG12 and above
version = get_pg_version(cur)
if (version >= 120000):
wal_sender_timeout = 10800 #3 hours

# Detect if the source is amazon-rds and convert to milliseconds
cur.execute("SELECT count(*) FROM pg_settings where name ilike '%rds%'")
is_rds = cur.fetchone()[0]

if is_rds == 0:
wal_sender_timeout = wal_sender_timeout
LOGGER.info("Set session wal_sender_timeout = {} seconds".format(wal_sender_timeout))
else:
wal_sender_timeout = wal_sender_timeout * 1000
LOGGER.info("Set session wal_sender_timeout = {} milliseconds".format(wal_sender_timeout))

cur.execute("SET SESSION wal_sender_timeout = {}".format(wal_sender_timeout))

try:
LOGGER.info("Request wal streaming from {} to {} (slot {})".format(int_to_lsn(start_lsn), int_to_lsn(end_lsn), slot))
# psycopg2 2.8.4 will send a keep-alive message to postgres every status_interval
Expand Down

0 comments on commit ecf04e5

Please sign in to comment.