{"record":{"id":"b369281ea6dbda46","repo":"mem0ai/mem0","slug":"index-name-creation-timed-out-after-max-retries","errorCode":null,"errorMessage":"Index {name} creation timed out after {max_retries} seconds","messagePattern":"Index (.+?) creation timed out after (.+?) seconds","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/opensearch.py","lineNumber":149,"sourceCode":"\n        if not self.client.indices.exists(index=name):\n            logger.warning(f\"Creating index {name}, it might take 1-2 minutes...\")\n            self.client.indices.create(index=name, body=index_settings)\n\n            # Wait for index to be ready\n            max_retries = 180  # 3 minutes timeout\n            retry_count = 0\n            while retry_count < max_retries:\n                try:\n                    # Check if index is ready by attempting a simple search\n                    self.client.search(index=name, body={\"query\": {\"match_all\": {}}})\n                    time.sleep(1)\n                    logger.info(f\"Index {name} is ready\")\n                    return\n                except Exception:\n                    retry_count += 1\n                    if retry_count == max_retries:\n                        raise TimeoutError(f\"Index {name} creation timed out after {max_retries} seconds\")\n                    time.sleep(0.5)\n\n    def insert(\n        self, vectors: List[List[float]], payloads: Optional[List[Dict]] = None, ids: Optional[List[str]] = None\n    ) -> List[OutputData]:\n        \"\"\"Insert vectors into the index.\"\"\"\n        if not ids:\n            ids = [str(i) for i in range(len(vectors))]\n\n        if payloads is None:\n            payloads = [{} for _ in range(len(vectors))]\n\n        for idx, vec in enumerate(vectors):\n            if vec is None:\n                raise ValueError(\n                    f\"Vector at index {idx} is null. \"\n                    f\"This usually means the embedding model failed to generate an embedding. \"\n                    f\"Check that your embedding model is configured correctly and returning valid vectors.\"","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/opensearch.py#L131-L167","documentation":"TimeoutError raised after create_col polls for up to 180 seconds (1s sleep per attempt, counted once per failed probe) waiting for the newly created OpenSearch index to answer a match_all search. If the index never becomes queryable in that window, the loop gives up and the constructor/create path fails.","triggerScenarios":"Creating an index on a cold/slow OpenSearch cluster (serverless cold start, undersized nodes), a cluster still forming shards, or one where index creation actually failed server-side while the poll only sees 'exception'.","commonSituations":"AWS OpenSearch Serverless first-hit latency; local OpenSearch under heavy load or low disk (watermark blocking shard allocation); security-timeout misconfig where search is rejected but creation 'succeeded'.","solutions":["Check cluster health and index state: GET _cluster/health and GET <index>/_search, and look for red status or unassigned shards","Freeze capacity: fix disk watermarks/heap, scale the cluster, then retry create_col","For serverless, pre-warm the collection or raise the retry budget by constructing when the cluster is warm","If creation genuinely failed, delete the half-created index and recreate"],"exampleFix":"# before\nstore = OpenSearch(...)  # create_col internally times out after 180s\n\n# after\n# pre-check cluster, then construct with warm cluster\nimport opensearchpy\nc = opensearchpy.OpenSearch(...)\nassert c.cluster.health()[\"status\"] in (\"green\", \"yellow\")\nstore = OpenSearch(...)","handlingStrategy":"retry","validationCode":"from opensearchpy import OpenSearch as OSClient\n\nclient = OSClient(...)\nhealth = client.cluster.health()\nif health.get(\"status\") == \"red\":\n    raise RuntimeError(\"cluster red; fix shards/disk before creating indexes\")\n# index creation is then likely to converge inside the poll window","typeGuard":null,"tryCatchPattern":"try:\n    store = OpenSearch(...)\nexcept TimeoutError as e:\n    if \"creation timed out\" in str(e):\n        time.sleep(30)\n        store = OpenSearch(...)  # retry once cluster has settled\n    else:\n        raise","preventionTips":["Verify cluster green/yellow and disk below watermarks before creating indexes","Pre-create indexes out of band (IaC) so app startup never waits on creation","Warm serverless collections before first deploy; raise capacity if creation consistently exceeds 3 minutes"],"tags":["opensearch","timeout","cluster-health","provisioning"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}