{"record":{"id":"0211f7c1cd7744f7","repo":"lionsoul2014/ip2region","slug":"failed-to-create-content-cached-searcher-s","errorCode":null,"errorMessage":"failed to create content cached searcher: %s","messagePattern":"failed to create content cached searcher: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"binding/nginx/src/ngx_http_ip2region_module.c","lineNumber":201,"sourceCode":"            }\n            return NGX_CONF_ERROR;\n        }\n    } else if (strcmp(cache_policy, \"content\") == 0) {\n        ip2region_searcher->c_buffer = xdb_load_content_from_file(db_path);\n        if (ip2region_searcher->c_buffer == NULL) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               \"failed to load xdb content: %s\", db_path);\n            xdb_free_header((void *)header);\n            if(ngx_http_ip2region_is_absolute_path(db_name) != NGX_OK) {\n                free(db_path);\n            }\n            return NGX_CONF_ERROR;\n        }\n\n        err = xdb_new_with_buffer(xdb_version, &ip2region_searcher->searcher, ip2region_searcher->c_buffer);\n        xdb_free_header((void *)header);\n        if (err != 0) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               \"failed to create content cached searcher: %s\", db_path);\n            xdb_free_content((void *)ip2region_searcher->c_buffer);\n            if(ngx_http_ip2region_is_absolute_path(db_name) != NGX_OK) {\n                free(db_path);\n            }\n            return NGX_CONF_ERROR;\n        }\n    } else {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           \"invalid cache policy, options: file/vectorIndex/content\");\n        xdb_free_header((void *)header);\n        if(ngx_http_ip2region_is_absolute_path(db_name) != NGX_OK) {\n            free(db_path);\n        }\n        return NGX_CONF_ERROR;\n    }\n\n    if(ngx_http_ip2region_is_absolute_path(db_name) != NGX_OK) {","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/nginx/src/ngx_http_ip2region_module.c#L183-L219","documentation":"nginx module init-time failure: with the content cache policy, xdb_load_content_from_file or the subsequent content-cached searcher creation failed, so the whole xdb could not be held in memory; the configuration is rejected with NGX_CONF_ERROR.","triggerScenarios":"xdb_new_with_buffer returns != 0: internal searcher allocation failed (out of memory), or the buffer/header is inconsistent with the expected xdb version (file changed or malformed between load and bind).","commonSituations":"Very large xdb + low available RAM (second allocation failure on top of the content load); corrupted or mismatched data file passing the earlier checks; race with a file deployment not applicable here since content is in memory but header validation may mismatch.","solutions":["Free up memory or raise container/cgroup limits — creating the searcher needs additional allocations on top of the loaded content.","Re-download a verified, complete xdb of the version your module expects.","If memory cannot be spared, use cache policy \"vectorIndex\" or \"file\".","Retry nginx start once after confirming no transient memory pressure."],"exampleFix":"ip2region_cache_policy content;\n# after (memory constrained)\nip2region_cache_policy file;","handlingStrategy":"validation","validationCode":"#!/bin/bash\n# extra headroom check: searcher creation allocates beyond the loaded content\nf=/data/ip2region.xdb\nneed=$(( $(stat -c%s \"$f\") / 1024 / 1024 + 128 ))\navail=$(free -m | awk 'NR==2{print $7}')\n[ $avail -gt $need ] && echo OK || echo \"WARN: need ~${need}MB free, have ${avail}MB\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep memory headroom above the full xdb size when using \"content\" policy.","Re-verify the xdb after any module upgrade.","If OOM persists, drop to \"vectorIndex\" or \"file\" policy.","Watch dmesg/OOM-killer logs around nginx reloads."],"tags":["nginx","xdb","memory","content-cache","config-startup"],"backgroundTag":"xdb-load-out-of-memory","analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}