We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Segmentation Fault when running bootstrap
So I've seen this happen in a couple different scenarios. I'm trying to run Sentry in Kubernetes. After getting everything installed, I go to bootstrap Snuba (create the Kafka topics). I've experienced this with both Confluent Kafka as well as Apache Kafka (and multiple versions of each). I've also experienced this in both Minikube and AWS EKS clusters. 

```
/usr/src/snuba# LOG_LEVEL=debug snuba bootstrap --force
2020-01-08 18:39:41,151 Using Kafka with ('kafka-cp-kafka-headless.kafka:9092',)
2020-01-08 18:39:41,165 Attempting to connect to Kafka (attempt 0)
Segmentation fault (core dumped)
```


But if I add some debug log statements, it starts to work....
Here is my `git diff` which caused it to work suddenly 

```
diff --git a/snuba/cli/bootstrap.py b/snuba/cli/bootstrap.py
index 28f52f8..23a85fb 100644
--- a/snuba/cli/bootstrap.py
+++ b/snuba/cli/bootstrap.py
@@ -35,7 +35,6 @@ def bootstrap(
     if kafka:
         logger.debug("Using Kafka with %r", bootstrap_server)
         from confluent_kafka.admin import AdminClient, NewTopic

         attempts = 0
         while True:
             try:
@@ -58,6 +57,7 @@ def bootstrap(
                 time.sleep(1)

         topics = []
+        logger.debug("Made Connection Successfully")
         for name in DATASET_NAMES:
             dataset = get_dataset(name)
             table_writer = dataset.get_table_writer()
@@ -71,14 +71,14 @@ def bootstrap(
                             replication_factor=topic_spec.replication_factor,
                         )
                     )
-
+        print("Created Topics")
         for topic, future in client.create_topics(topics).items():
             try:
                 future.result()
                 logger.info("Topic %s created", topic)
             except Exception as e:
                 logger.error("Failed to create topic %s", topic, exc_info=e)
-
+        print("Actually created topics now")
     from snuba.clickhouse.native import ClickhousePool

     attempts = 0
```

It started to work after the 3rd log statement was added. 

Has anyone else experienced this?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `snuba/cli/migrate.py`
Content:
```
1 import logging
2 import sys
3 import click
4 from clickhouse_driver import Client
5 from typing import Optional
6 
7 from snuba import settings
8 from snuba.datasets.factory import get_dataset, DATASET_NAMES
9 from snuba.util import local_dataset_mode
10 
11 
12 @click.command()
13 @click.option("--log-level", default=settings.LOG_LEVEL, help="Logging level to use.")
14 @click.option(
15     "--dataset",
16     "dataset_name",
17     type=click.Choice(DATASET_NAMES),
18     help="The dataset to target",
19 )
20 def migrate(*, log_level: str, dataset_name: Optional[str]) -> None:
21     from snuba.migrate import logger, run
22 
23     logging.basicConfig(
24         level=getattr(logging, log_level.upper()), format="%(asctime)s %(message)s"
25     )
26     dataset_names = [dataset_name] if dataset_name else DATASET_NAMES
27     for name in dataset_names:
28         dataset = get_dataset(name)
29         logger.info("Migrating dataset %s", name)
30         if not local_dataset_mode():
31             logger.error("The migration tool can only work on local dataset mode.")
32             sys.exit(1)
33 
34         clickhouse = Client(
35             host=settings.CLICKHOUSE_HOST, port=settings.CLICKHOUSE_PORT,
36         )
37 
38         run(clickhouse, dataset)
39
```

Path: `snuba/cli/bootstrap.py`
Content:
```
1 import logging
2 import click
3 from typing import Sequence
4 
5 from snuba import settings
6 from snuba.datasets.factory import get_dataset, DATASET_NAMES
7 
8 
9 @click.command()
10 @click.option(
11     "--bootstrap-server",
12     default=settings.DEFAULT_BROKERS,
13     multiple=True,
14     help="Kafka bootstrap server to use.",
15 )
16 @click.option("--kafka/--no-kafka", default=True)
17 @click.option("--force", is_flag=True)
18 @click.option("--log-level", default=settings.LOG_LEVEL, help="Logging level to use.")
19 def bootstrap(
20     *, bootstrap_server: Sequence[str], kafka: bool, force: bool, log_level: str
21 ) -> None:
22     """
23     Warning: Not intended to be used in production yet.
24     """
25     if not force:
26         raise click.ClickException("Must use --force to run")
27 
28     logger = logging.getLogger("snuba.bootstrap")
29     logging.basicConfig(
30         level=getattr(logging, log_level.upper()), format="%(asctime)s %(message)s"
31     )
32 
33     import time
34 
35     if kafka:
36         logger.debug("Using Kafka with %r", bootstrap_server)
37         from confluent_kafka.admin import AdminClient, NewTopic
38 
39         attempts = 0
40         while True:
41             try:
42                 logger.debug("Attempting to connect to Kafka (attempt %d)", attempts)
43                 client = AdminClient(
44                     {
45                         "bootstrap.servers": ",".join(bootstrap_server),
46                         "socket.timeout.ms": 1000,
47                     }
48                 )
49                 client.list_topics(timeout=1)
50                 break
51             except Exception as e:
52                 logger.error(
53                     "Connection to Kafka failed (attempt %d)", attempts, exc_info=e
54                 )
55                 attempts += 1
56                 if attempts == 60:
57                     raise
58                 time.sleep(1)
59 
60         topics = []
61         for name in DATASET_NAMES:
62             dataset = get_dataset(name)
63             table_writer = dataset.get_table_writer()
64             if table_writer:
65                 stream_loader = table_writer.get_stream_loader()
66                 for topic_spec in stream_loader.get_all_topic_specs():
67                     topics.append(
68                         NewTopic(
69                             topic_spec.topic_name,
70                             num_partitions=topic_spec.partitions_number,
71                             replication_factor=topic_spec.replication_factor,
72                         )
73                     )
74 
75         for topic, future in client.create_topics(topics).items():
76             try:
77                 future.result()
78                 logger.info("Topic %s created", topic)
79             except Exception as e:
80                 logger.error("Failed to create topic %s", topic, exc_info=e)
81 
82     from snuba.clickhouse.native import ClickhousePool
83 
84     attempts = 0
85     while True:
86         try:
87             logger.debug("Attempting to connect to Clickhouse (attempt %d)", attempts)
88             ClickhousePool().execute("SELECT 1")
89             break
90         except Exception as e:
91             logger.error(
92                 "Connection to Clickhouse failed (attempt %d)", attempts, exc_info=e
93             )
94             attempts += 1
95             if attempts == 60:
96                 raise
97             time.sleep(1)
98 
99     # Need to better figure out if we are configured to use replicated
100     # tables or distributed tables, etc.
101 
102     # Create the tables for every dataset.
103     for name in DATASET_NAMES:
104         dataset = get_dataset(name)
105 
106         logger.debug("Creating tables for dataset %s", name)
107         for statement in dataset.get_dataset_schemas().get_create_statements():
108             logger.debug("Executing:\n%s", statement)
109             ClickhousePool().execute(statement)
110         logger.info("Tables for dataset %s created.", name)
111
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/snuba/cli/bootstrap.py b/snuba/cli/bootstrap.py
--- a/snuba/cli/bootstrap.py
+++ b/snuba/cli/bootstrap.py
@@ -57,22 +57,28 @@
                     raise
                 time.sleep(1)
 
-        topics = []
+        topics = {}
         for name in DATASET_NAMES:
             dataset = get_dataset(name)
             table_writer = dataset.get_table_writer()
             if table_writer:
                 stream_loader = table_writer.get_stream_loader()
                 for topic_spec in stream_loader.get_all_topic_specs():
-                    topics.append(
-                        NewTopic(
-                            topic_spec.topic_name,
-                            num_partitions=topic_spec.partitions_number,
-                            replication_factor=topic_spec.replication_factor,
-                        )
+                    if topic_spec.topic_name in topics:
+                        continue
+                    logger.debug(
+                        "Adding topic %s to creation list", topic_spec.topic_name
+                    )
+                    topics[topic_spec.topic_name] = NewTopic(
+                        topic_spec.topic_name,
+                        num_partitions=topic_spec.partitions_number,
+                        replication_factor=topic_spec.replication_factor,
                     )
 
-        for topic, future in client.create_topics(topics).items():
+        logger.debug("Initiating topic creation")
+        for topic, future in client.create_topics(
+            list(topics.values()), operation_timeout=1
+        ).items():
             try:
                 future.result()
                 logger.info("Topic %s created", topic)
diff --git a/snuba/cli/migrate.py b/snuba/cli/migrate.py
--- a/snuba/cli/migrate.py
+++ b/snuba/cli/migrate.py
@@ -23,13 +23,15 @@
     logging.basicConfig(
         level=getattr(logging, log_level.upper()), format="%(asctime)s %(message)s"
     )
+
+    if not local_dataset_mode():
+        logger.error("The migration tool can only work on local dataset mode.")
+        sys.exit(1)
+
     dataset_names = [dataset_name] if dataset_name else DATASET_NAMES
     for name in dataset_names:
         dataset = get_dataset(name)
         logger.info("Migrating dataset %s", name)
-        if not local_dataset_mode():
-            logger.error("The migration tool can only work on local dataset mode.")
-            sys.exit(1)
 
         clickhouse = Client(
             host=settings.CLICKHOUSE_HOST, port=settings.CLICKHOUSE_PORT,

{"golden_diff": "diff --git a/snuba/cli/bootstrap.py b/snuba/cli/bootstrap.py\n--- a/snuba/cli/bootstrap.py\n+++ b/snuba/cli/bootstrap.py\n@@ -57,22 +57,28 @@\n                     raise\n                 time.sleep(1)\n \n-        topics = []\n+        topics = {}\n         for name in DATASET_NAMES:\n             dataset = get_dataset(name)\n             table_writer = dataset.get_table_writer()\n             if table_writer:\n                 stream_loader = table_writer.get_stream_loader()\n                 for topic_spec in stream_loader.get_all_topic_specs():\n-                    topics.append(\n-                        NewTopic(\n-                            topic_spec.topic_name,\n-                            num_partitions=topic_spec.partitions_number,\n-                            replication_factor=topic_spec.replication_factor,\n-                        )\n+                    if topic_spec.topic_name in topics:\n+                        continue\n+                    logger.debug(\n+                        \"Adding topic %s to creation list\", topic_spec.topic_name\n+                    )\n+                    topics[topic_spec.topic_name] = NewTopic(\n+                        topic_spec.topic_name,\n+                        num_partitions=topic_spec.partitions_number,\n+                        replication_factor=topic_spec.replication_factor,\n                     )\n \n-        for topic, future in client.create_topics(topics).items():\n+        logger.debug(\"Initiating topic creation\")\n+        for topic, future in client.create_topics(\n+            list(topics.values()), operation_timeout=1\n+        ).items():\n             try:\n                 future.result()\n                 logger.info(\"Topic %s created\", topic)\ndiff --git a/snuba/cli/migrate.py b/snuba/cli/migrate.py\n--- a/snuba/cli/migrate.py\n+++ b/snuba/cli/migrate.py\n@@ -23,13 +23,15 @@\n     logging.basicConfig(\n         level=getattr(logging, log_level.upper()), format=\"%(asctime)s %(message)s\"\n     )\n+\n+    if not local_dataset_mode():\n+        logger.error(\"The migration tool can only work on local dataset mode.\")\n+        sys.exit(1)\n+\n     dataset_names = [dataset_name] if dataset_name else DATASET_NAMES\n     for name in dataset_names:\n         dataset = get_dataset(name)\n         logger.info(\"Migrating dataset %s\", name)\n-        if not local_dataset_mode():\n-            logger.error(\"The migration tool can only work on local dataset mode.\")\n-            sys.exit(1)\n \n         clickhouse = Client(\n             host=settings.CLICKHOUSE_HOST, port=settings.CLICKHOUSE_PORT,\n", "issue": "Segmentation Fault when running bootstrap\nSo I've seen this happen in a couple different scenarios. I'm trying to run Sentry in Kubernetes. After getting everything installed, I go to bootstrap Snuba (create the Kafka topics). I've experienced this with both Confluent Kafka as well as Apache Kafka (and multiple versions of each). I've also experienced this in both Minikube and AWS EKS clusters. \r\n\r\n```\r\n/usr/src/snuba# LOG_LEVEL=debug snuba bootstrap --force\r\n2020-01-08 18:39:41,151 Using Kafka with ('kafka-cp-kafka-headless.kafka:9092',)\r\n2020-01-08 18:39:41,165 Attempting to connect to Kafka (attempt 0)\r\nSegmentation fault (core dumped)\r\n```\r\n\r\n\r\nBut if I add some debug log statements, it starts to work....\r\nHere is my `git diff` which caused it to work suddenly \r\n\r\n```\r\ndiff --git a/snuba/cli/bootstrap.py b/snuba/cli/bootstrap.py\r\nindex 28f52f8..23a85fb 100644\r\n--- a/snuba/cli/bootstrap.py\r\n+++ b/snuba/cli/bootstrap.py\r\n@@ -35,7 +35,6 @@ def bootstrap(\r\n     if kafka:\r\n         logger.debug(\"Using Kafka with %r\", bootstrap_server)\r\n         from confluent_kafka.admin import AdminClient, NewTopic\r\n\r\n         attempts = 0\r\n         while True:\r\n             try:\r\n@@ -58,6 +57,7 @@ def bootstrap(\r\n                 time.sleep(1)\r\n\r\n         topics = []\r\n+        logger.debug(\"Made Connection Successfully\")\r\n         for name in DATASET_NAMES:\r\n             dataset = get_dataset(name)\r\n             table_writer = dataset.get_table_writer()\r\n@@ -71,14 +71,14 @@ def bootstrap(\r\n                             replication_factor=topic_spec.replication_factor,\r\n                         )\r\n                     )\r\n-\r\n+        print(\"Created Topics\")\r\n         for topic, future in client.create_topics(topics).items():\r\n             try:\r\n                 future.result()\r\n                 logger.info(\"Topic %s created\", topic)\r\n             except Exception as e:\r\n                 logger.error(\"Failed to create topic %s\", topic, exc_info=e)\r\n-\r\n+        print(\"Actually created topics now\")\r\n     from snuba.clickhouse.native import ClickhousePool\r\n\r\n     attempts = 0\r\n```\r\n\r\nIt started to work after the 3rd log statement was added. \r\n\r\nHas anyone else experienced this?\n", "before_files": [{"content": "import logging\nimport sys\nimport click\nfrom clickhouse_driver import Client\nfrom typing import Optional\n\nfrom snuba import settings\nfrom snuba.datasets.factory import get_dataset, DATASET_NAMES\nfrom snuba.util import local_dataset_mode\n\n\n@click.command()\n@click.option(\"--log-level\", default=settings.LOG_LEVEL, help=\"Logging level to use.\")\n@click.option(\n    \"--dataset\",\n    \"dataset_name\",\n    type=click.Choice(DATASET_NAMES),\n    help=\"The dataset to target\",\n)\ndef migrate(*, log_level: str, dataset_name: Optional[str]) -> None:\n    from snuba.migrate import logger, run\n\n    logging.basicConfig(\n        level=getattr(logging, log_level.upper()), format=\"%(asctime)s %(message)s\"\n    )\n    dataset_names = [dataset_name] if dataset_name else DATASET_NAMES\n    for name in dataset_names:\n        dataset = get_dataset(name)\n        logger.info(\"Migrating dataset %s\", name)\n        if not local_dataset_mode():\n            logger.error(\"The migration tool can only work on local dataset mode.\")\n            sys.exit(1)\n\n        clickhouse = Client(\n            host=settings.CLICKHOUSE_HOST, port=settings.CLICKHOUSE_PORT,\n        )\n\n        run(clickhouse, dataset)\n", "path": "snuba/cli/migrate.py"}, {"content": "import logging\nimport click\nfrom typing import Sequence\n\nfrom snuba import settings\nfrom snuba.datasets.factory import get_dataset, DATASET_NAMES\n\n\n@click.command()\n@click.option(\n    \"--bootstrap-server\",\n    default=settings.DEFAULT_BROKERS,\n    multiple=True,\n    help=\"Kafka bootstrap server to use.\",\n)\n@click.option(\"--kafka/--no-kafka\", default=True)\n@click.option(\"--force\", is_flag=True)\n@click.option(\"--log-level\", default=settings.LOG_LEVEL, help=\"Logging level to use.\")\ndef bootstrap(\n    *, bootstrap_server: Sequence[str], kafka: bool, force: bool, log_level: str\n) -> None:\n    \"\"\"\n    Warning: Not intended to be used in production yet.\n    \"\"\"\n    if not force:\n        raise click.ClickException(\"Must use --force to run\")\n\n    logger = logging.getLogger(\"snuba.bootstrap\")\n    logging.basicConfig(\n        level=getattr(logging, log_level.upper()), format=\"%(asctime)s %(message)s\"\n    )\n\n    import time\n\n    if kafka:\n        logger.debug(\"Using Kafka with %r\", bootstrap_server)\n        from confluent_kafka.admin import AdminClient, NewTopic\n\n        attempts = 0\n        while True:\n            try:\n                logger.debug(\"Attempting to connect to Kafka (attempt %d)\", attempts)\n                client = AdminClient(\n                    {\n                        \"bootstrap.servers\": \",\".join(bootstrap_server),\n                        \"socket.timeout.ms\": 1000,\n                    }\n                )\n                client.list_topics(timeout=1)\n                break\n            except Exception as e:\n                logger.error(\n                    \"Connection to Kafka failed (attempt %d)\", attempts, exc_info=e\n                )\n                attempts += 1\n                if attempts == 60:\n                    raise\n                time.sleep(1)\n\n        topics = []\n        for name in DATASET_NAMES:\n            dataset = get_dataset(name)\n            table_writer = dataset.get_table_writer()\n            if table_writer:\n                stream_loader = table_writer.get_stream_loader()\n                for topic_spec in stream_loader.get_all_topic_specs():\n                    topics.append(\n                        NewTopic(\n                            topic_spec.topic_name,\n                            num_partitions=topic_spec.partitions_number,\n                            replication_factor=topic_spec.replication_factor,\n                        )\n                    )\n\n        for topic, future in client.create_topics(topics).items():\n            try:\n                future.result()\n                logger.info(\"Topic %s created\", topic)\n            except Exception as e:\n                logger.error(\"Failed to create topic %s\", topic, exc_info=e)\n\n    from snuba.clickhouse.native import ClickhousePool\n\n    attempts = 0\n    while True:\n        try:\n            logger.debug(\"Attempting to connect to Clickhouse (attempt %d)\", attempts)\n            ClickhousePool().execute(\"SELECT 1\")\n            break\n        except Exception as e:\n            logger.error(\n                \"Connection to Clickhouse failed (attempt %d)\", attempts, exc_info=e\n            )\n            attempts += 1\n            if attempts == 60:\n                raise\n            time.sleep(1)\n\n    # Need to better figure out if we are configured to use replicated\n    # tables or distributed tables, etc.\n\n    # Create the tables for every dataset.\n    for name in DATASET_NAMES:\n        dataset = get_dataset(name)\n\n        logger.debug(\"Creating tables for dataset %s\", name)\n        for statement in dataset.get_dataset_schemas().get_create_statements():\n            logger.debug(\"Executing:\\n%s\", statement)\n            ClickhousePool().execute(statement)\n        logger.info(\"Tables for dataset %s created.\", name)\n", "path": "snuba/cli/bootstrap.py"}], "after_files": [{"content": "import logging\nimport sys\nimport click\nfrom clickhouse_driver import Client\nfrom typing import Optional\n\nfrom snuba import settings\nfrom snuba.datasets.factory import get_dataset, DATASET_NAMES\nfrom snuba.util import local_dataset_mode\n\n\n@click.command()\n@click.option(\"--log-level\", default=settings.LOG_LEVEL, help=\"Logging level to use.\")\n@click.option(\n    \"--dataset\",\n    \"dataset_name\",\n    type=click.Choice(DATASET_NAMES),\n    help=\"The dataset to target\",\n)\ndef migrate(*, log_level: str, dataset_name: Optional[str]) -> None:\n    from snuba.migrate import logger, run\n\n    logging.basicConfig(\n        level=getattr(logging, log_level.upper()), format=\"%(asctime)s %(message)s\"\n    )\n\n    if not local_dataset_mode():\n        logger.error(\"The migration tool can only work on local dataset mode.\")\n        sys.exit(1)\n\n    dataset_names = [dataset_name] if dataset_name else DATASET_NAMES\n    for name in dataset_names:\n        dataset = get_dataset(name)\n        logger.info(\"Migrating dataset %s\", name)\n\n        clickhouse = Client(\n            host=settings.CLICKHOUSE_HOST, port=settings.CLICKHOUSE_PORT,\n        )\n\n        run(clickhouse, dataset)\n", "path": "snuba/cli/migrate.py"}, {"content": "import logging\nimport click\nfrom typing import Sequence\n\nfrom snuba import settings\nfrom snuba.datasets.factory import get_dataset, DATASET_NAMES\n\n\n@click.command()\n@click.option(\n    \"--bootstrap-server\",\n    default=settings.DEFAULT_BROKERS,\n    multiple=True,\n    help=\"Kafka bootstrap server to use.\",\n)\n@click.option(\"--kafka/--no-kafka\", default=True)\n@click.option(\"--force\", is_flag=True)\n@click.option(\"--log-level\", default=settings.LOG_LEVEL, help=\"Logging level to use.\")\ndef bootstrap(\n    *, bootstrap_server: Sequence[str], kafka: bool, force: bool, log_level: str\n) -> None:\n    \"\"\"\n    Warning: Not intended to be used in production yet.\n    \"\"\"\n    if not force:\n        raise click.ClickException(\"Must use --force to run\")\n\n    logger = logging.getLogger(\"snuba.bootstrap\")\n    logging.basicConfig(\n        level=getattr(logging, log_level.upper()), format=\"%(asctime)s %(message)s\"\n    )\n\n    import time\n\n    if kafka:\n        logger.debug(\"Using Kafka with %r\", bootstrap_server)\n        from confluent_kafka.admin import AdminClient, NewTopic\n\n        attempts = 0\n        while True:\n            try:\n                logger.debug(\"Attempting to connect to Kafka (attempt %d)\", attempts)\n                client = AdminClient(\n                    {\n                        \"bootstrap.servers\": \",\".join(bootstrap_server),\n                        \"socket.timeout.ms\": 1000,\n                    }\n                )\n                client.list_topics(timeout=1)\n                break\n            except Exception as e:\n                logger.error(\n                    \"Connection to Kafka failed (attempt %d)\", attempts, exc_info=e\n                )\n                attempts += 1\n                if attempts == 60:\n                    raise\n                time.sleep(1)\n\n        topics = {}\n        for name in DATASET_NAMES:\n            dataset = get_dataset(name)\n            table_writer = dataset.get_table_writer()\n            if table_writer:\n                stream_loader = table_writer.get_stream_loader()\n                for topic_spec in stream_loader.get_all_topic_specs():\n                    if topic_spec.topic_name in topics:\n                        continue\n                    logger.debug(\n                        \"Adding topic %s to creation list\", topic_spec.topic_name\n                    )\n                    topics[topic_spec.topic_name] = NewTopic(\n                        topic_spec.topic_name,\n                        num_partitions=topic_spec.partitions_number,\n                        replication_factor=topic_spec.replication_factor,\n                    )\n\n        logger.debug(\"Initiating topic creation\")\n        for topic, future in client.create_topics(\n            list(topics.values()), operation_timeout=1\n        ).items():\n            try:\n                future.result()\n                logger.info(\"Topic %s created\", topic)\n            except Exception as e:\n                logger.error(\"Failed to create topic %s\", topic, exc_info=e)\n\n    from snuba.clickhouse.native import ClickhousePool\n\n    attempts = 0\n    while True:\n        try:\n            logger.debug(\"Attempting to connect to Clickhouse (attempt %d)\", attempts)\n            ClickhousePool().execute(\"SELECT 1\")\n            break\n        except Exception as e:\n            logger.error(\n                \"Connection to Clickhouse failed (attempt %d)\", attempts, exc_info=e\n            )\n            attempts += 1\n            if attempts == 60:\n                raise\n            time.sleep(1)\n\n    # Need to better figure out if we are configured to use replicated\n    # tables or distributed tables, etc.\n\n    # Create the tables for every dataset.\n    for name in DATASET_NAMES:\n        dataset = get_dataset(name)\n\n        logger.debug(\"Creating tables for dataset %s\", name)\n        for statement in dataset.get_dataset_schemas().get_create_statements():\n            logger.debug(\"Executing:\\n%s\", statement)\n            ClickhousePool().execute(statement)\n        logger.info(\"Tables for dataset %s created.\", name)\n", "path": "snuba/cli/bootstrap.py"}]}