jayvynl / django-clickhouse-backend

Django clickhouse database backend.
MIT License
130 stars 21 forks source link

[BUG] permanent warnings and reconnects from clickhouse-driver #85

Closed SokolovskiR closed 5 months ago

SokolovskiR commented 6 months ago

Describe the bug First of all thank you for this useful library!

We have a Django app running in a docker container and couple times a day we see the following warnings in container logs concerning the connection to cklickhouse from clickhouse-driver.

Screenshot 2024-05-31 at 08 56 41

We use these database settings in django:

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "xxx",
        "USER": os.getenv("POSTGRES_USER", "xxx"),
        "PASSWORD": os.getenv("POSTGRES_PASSWORD", "xxx"),
        "HOST": os.getenv("POSTGRES_HOST", "xxx"),
        "PORT": int(os.getenv("POSTGRES_PORT", "5432"))
    },
    "clickhouse": {
        "ENGINE": "clickhouse_backend.backend",
        "NAME": "default",
        "HOST": os.getenv("CLICKHOUSE_HOST", "xxx"),
        "USER": os.getenv("CLICKHOUSE_USER_P", "xxx"),
        "PASSWORD": os.getenv("CLICKHOUSE_PASSWORD_P", "xxx"),
        "PORT": int(os.getenv("CLICKHOUSE_PORT", "9000"))
    }
}

We also have some another python app using clickhouse-driver only, without Django and django-clickhouse-backend and we do not see these warnings there.

To Reproduce Run a django app in docker container using the specs below.

Expected behavior No such log entries.

Versions

jayvynl commented 5 months ago

This is ok, because clickhouse connection is reused between queries. If there are no queries for a long time, I guess the connection will be closed by the server.