{"record":{"id":"b2fad8337a547a35","repo":"MyCATApache/Mycat-Server","slug":"can-t-find-cache-pool-poolname","errorCode":null,"errorMessage":"can't find cache pool:{poolName}","messagePattern":"can't find cache pool:(.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/cache/CacheService.java","lineNumber":177,"sourceCode":"\tprivate CachePoolFactory getCacheFact(String type) {\n\t\tCachePoolFactory facty = this.poolFactorys.get(type);\n\t\tif (facty == null) {\n\t\t\tthrow new RuntimeException(\"CachePoolFactory not defined for type:\"\n\t\t\t\t\t+ type);\n\t\t}\n\t\treturn facty;\n\t}\n\n\t/**\n\t * get cache pool by name ,caller should cache result\n\t * \n\t * @param poolName\n\t * @return CachePool\n\t */\n\tpublic CachePool getCachePool(String poolName) {\n\t\tCachePool pool = allPools.get(poolName);\n\t\tif (pool == null) {\n\t\t\tthrow new IllegalArgumentException(\"can't find cache pool:\"\n\t\t\t\t\t+ poolName);\n\t\t} else {\n\t\t\treturn pool;\n\t\t}\n\n\t}\n\n\tpublic void clearCache() {\n\n\t\tlogger.info(\"clear all cache pool \");\n\t\tfor (CachePool pool : allPools.values()) {\n\n\t\t\tpool.clearCache();\n\t\t}\n\n\t}\n\n}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/cache/CacheService.java#L159-L195","documentation":"getCachePool retrieves a CachePool by name from allPools, which is populated from the cache configuration at CacheService init. When the requested pool name was never configured (or init skipped it due to an earlier error), it throws IllegalArgumentException. Callers like RouteService depend on pools such as RouteService cache or sqlRouteCache existing.","triggerScenarios":"Calling CacheService.getCachePool(\"someName\") where someName is absent from the cache config: e.g. RouteService requests its route cache but the cache section was removed, renamed, or the cacheServerPort/cache config file failed to define it.","commonSituations":"Deleting or renaming a cache entry in the Mycat cache configuration while code/system defaults still reference the old name; cache initialization silently skipped a pool because its factory type was invalid; copy-paste config between environments missing pool entries.","solutions":["Add the missing cache pool entry to your Mycat cache configuration with the exact name being requested (e.g. 'sqlRouteCache','ER sqlcache')","Verify with logs whether cache init failed earlier for that pool (e.g. bad type) and fix the root cause","Grep the code/config for the pool name to confirm the exact spelling expected by the caller (RouteService)","If you intentionally don't need that cache, configure the related feature to disable cache usage rather than leaving the pool undefined"],"exampleFix":"// before (cache config missing pool)\n<cache name=\"sqlRouteCache2\" type=\"ehcache\" ... />\n// after (name matches what getCachePool requests)\n<cache name=\"sqlRouteCache\" type=\"ehcache\" ... />","handlingStrategy":"try-catch","validationCode":"// ensure pool exists before use\nif (!cacheService.getAllCachePools().containsKey(poolName)) {\n    LOG.warn(\"cache pool {} not configured, skipping cache usage\", poolName);\n    return null;\n}","typeGuard":null,"tryCatchPattern":"try {\n    CachePool pool = cacheService.getCachePool(poolName);\n    return pool.get(key);\n} catch (IllegalArgumentException e) {\n    LOG.warn(\"cache pool {} missing, bypassing cache\", poolName, e);\n    return loadFromDatabase(key); // fallback, never fail the query for cache\n}","preventionTips":["Define every pool name referenced by code/system defaults in the cache config","Never let a cache lookup failure fail the business query — wrap with fallback","After config changes, enumerate allPools at startup and compare with required pool names"],"tags":["cache","configuration","lookup","mycat"],"backgroundTag":"resource-not-found","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}