-
Notifications
You must be signed in to change notification settings - Fork 100
added statement_timeout to connection_config #73
base: master
Are you sure you want to change the base?
Conversation
tap_postgres/db.py
Outdated
@@ -49,6 +49,10 @@ def open_connection(conn_config, logical_replication=False): | |||
'connect_timeout': 30 | |||
} | |||
|
|||
statement_timeout = conn_config.get('statement_timeout') | |||
if statement_timeout is not None: | |||
cfg['options'] = f'-c statement_timeout={statement_timeout}s' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is cool, but can we try making it more generic and prepare it somehow to accept any valid postgres options?
What if we introduce a new options
key in config.json
:
{
"host": "x",
"port": "x",
"user": "x",
"password": "x",
"dbname": "x",
"options": [
"statement_timeout=60s",
"another_option=120",
"and_another_option=180"
]
}
And in the code it would be something like this:
cfg['options'] = ' '.join(map('-c {0}'.format, conn_config.get('options',[])))
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, how we want to deal with the case if the options
key in the config.json
is not a list but a string or a number? Can we raise an exception with a meaningful error message in that case?
Adding some sort of unit test for open_connection
would be great as well. Maybe we need to mock the psycopg2.connect
?
Problem
Getting this error in tap-postgres. psycopg2.errors.QueryCanceled: canceling statement due to statement timeout
Proposed changes
Added statement_timeout in connection config so that if it is provided then the connection will be held for long time.
Types of changes
What types of changes does your code introduce to PipelineWise?
Put an
x
in the boxes that applyChecklist
setup.py
is an individual PR and not mixed with feature or bugfix PRs[AP-NNNN]
(if applicable. AP-NNNN = JIRA ID)AP-NNN
(if applicable. AP-NNN = JIRA ID)