This repository was archived by the owner on Sep 23, 2024. It is now read-only.
added statement_timeout to connection_config#73
Open
alamirfan wants to merge 3 commits intotransferwise:masterfrom
Open
added statement_timeout to connection_config#73alamirfan wants to merge 3 commits intotransferwise:masterfrom
alamirfan wants to merge 3 commits intotransferwise:masterfrom
Conversation
DouweM
reviewed
Jan 7, 2021
koszti
suggested changes
Jan 13, 2021
tap_postgres/db.py
Outdated
|
|
||
| statement_timeout = conn_config.get('statement_timeout') | ||
| if statement_timeout is not None: | ||
| cfg['options'] = f'-c statement_timeout={statement_timeout}s' |
Contributor
There was a problem hiding this comment.
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?
Contributor
There was a problem hiding this comment.
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 ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
xin the boxes that applyChecklist
setup.pyis 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)