diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml index a7db2976dff..70047a54905 100644 --- a/.github/workflows/ci-backend.yml +++ b/.github/workflows/ci-backend.yml @@ -155,7 +155,9 @@ jobs: fetch-depth: 1 - name: Start stack with Docker Compose - run: docker-compose -f ee/docker-compose.ch.yml up -d ${{ matrix.foss && 'db' || 'db clickhouse zookeeper kafka' }} + run: | + docker-compose -f ee/docker-compose.ch.yml down + docker-compose -f ee/docker-compose.ch.yml up -d ${{ matrix.foss && 'db' || 'db clickhouse zookeeper kafka' }} - name: Set up Python uses: actions/setup-python@v2 @@ -275,7 +277,9 @@ jobs: cat multi_tenancy_settings.py >> deploy/posthog/settings.py cat requirements.txt >> deploy/requirements.txt - name: Start stack with Docker Compose - run: docker-compose -f deploy/ee/docker-compose.ch.yml up -d db clickhouse zookeeper kafka + run: | + docker-compose -f deploy/ee/docker-compose.ch.yml down + docker-compose -f deploy/ee/docker-compose.ch.yml up -d db clickhouse zookeeper kafka - name: Set up Python 3.8 uses: actions/setup-python@v2 with: diff --git a/ee/clickhouse/client.py b/ee/clickhouse/client.py index cee660c51df..1d69b86d3fb 100644 --- a/ee/clickhouse/client.py +++ b/ee/clickhouse/client.py @@ -47,6 +47,21 @@ QUERY_TIMEOUT_THREAD = get_timer_thread("ee.clickhouse.client", SLOW_QUERY_THRES _request_information: Optional[Dict] = None +def default_client(): + """ + Return a bare bones client for use in places where we are only interested in general ClickHouse state + DO NOT USE THIS FOR QUERYING DATA + """ + return SyncClient( + host=CLICKHOUSE_HOST, + secure=CLICKHOUSE_SECURE, + user=CLICKHOUSE_USER, + password=CLICKHOUSE_PASSWORD, + ca_certs=CLICKHOUSE_CA, + verify=CLICKHOUSE_VERIFY, + ) + + def make_ch_pool(**overrides) -> ChPool: kwargs = { "host": CLICKHOUSE_HOST, diff --git a/posthog/version_requirement.py b/posthog/version_requirement.py index 4f71c6cfcf3..dd7ed1b8a78 100644 --- a/posthog/version_requirement.py +++ b/posthog/version_requirement.py @@ -48,9 +48,10 @@ class ServiceVersionRequirement: return self.version_string_to_semver(version) def get_clickhouse_version(self): - from ee.clickhouse.client import sync_execute + from ee.clickhouse.client import default_client - rows = sync_execute("SELECT version()") + client = default_client() + rows = client.execute("SELECT version()") version = rows[0][0] return self.version_string_to_semver(version)