Repository navigation
ref(reader): Move reader instantiation to snuba.environment - #780
Merged
Merged
Conversation
fpacifici
approved these changes
Feb 19, 2020
| client_settings={"readonly": True}, | ||
| ) | ||
|
|
||
| reader: Reader[ClickhouseQuery] = NativeDriverReader(clickhouse_ro) |
Contributor
There was a problem hiding this comment.
This will be reused only on split queries or any other request that runs more than one query. Is this correct ?
Contributor
Author
There was a problem hiding this comment.
No, this is a global and instantiated at startup
Contributor
There was a problem hiding this comment.
So I guess we will have to ensure thread safety as well when we get to the http reader if that is stateful right ?
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This removes the
readerparameter fromraw_query, since there is no way to actually set it without modifications toparse_and_run_queryand correspondinglysplit_queryand it's inner functions.The HTTP reader will have state (the HTTP connection pool), so reinstantiating it on each call to
parse_and_run_queryisn't ideal — it will be better to instantiate aReaderinstance and reuse it. Since the ClickHouse cluster address is a global setting, it (unfortunately) seems appropriate to make this global state, similar to the native driver pool.I think that in the future, we'll want the table storages themselves to provide the writer and reader interfaces (since I assume we'll want table storages to be able to reference different ClickHouse clusters) but that seems like a reasonably far future.