{"record":{"id":"214e1eb426addc5d","repo":"apache/druid","slug":"could-not-populate-cache","errorCode":null,"errorMessage":"Could not populate cache","messagePattern":"Could not populate cache","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/src/main/java/org/apache/druid/client/cache/BackgroundCachePopulator.java","lineNumber":147,"sourceCode":"          JacksonUtils.writeObjectUsingSerializerProvider(gen, serializers, result);\n\n          if (maxEntrySize > 0 && bytes.size() > maxEntrySize) {\n            cachePopulatorStats.incrementOversized();\n            return;\n          }\n        }\n      }\n\n      if (maxEntrySize > 0 && bytes.size() > maxEntrySize) {\n        cachePopulatorStats.incrementOversized();\n        return;\n      }\n\n      cache.put(cacheKey, bytes.toByteArray());\n      cachePopulatorStats.incrementOk();\n    }\n    catch (Exception e) {\n      log.warn(e, \"Could not populate cache\");\n      cachePopulatorStats.incrementError();\n    }\n  }\n}\n","sourceCodeStart":129,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/client/cache/BackgroundCachePopulator.java#L129-L152","documentation":"BackgroundCachePopulator serializes query results and writes them into the cache on a background thread. Any exception during cache.put (serialization size issues, cache failures, interruption) is caught, logged as 'Could not populate cache', and counted in cachePopulatorStats as an error. Caching is best-effort; the query result is unaffected.","triggerScenarios":"The background thread calls populateCache and cache.put throws — e.g. cache backend failure (memcached connection lost), value exceeds cache limits, or serialization of the result bytes fails.","commonSituations":"Memcached or caffeine backend unavailable/evicting aggressively; oversized result sets exceeding cache entry limits; cache node restarted during heavy load; disk/heap pressure on cache host.","solutions":["Check cache backend health (memcached connectivity, memory) and fix the underlying put failure using the logged exception stack trace.","Lower cache entry size limits or enable result chunking if large results exceed cache limits.","Confirm the cache configuration (type, hosts, timeouts) in the query cache settings is correct.","Accept as benign if frequent only under overload — stats are surfaced via cachePopulator metrics for monitoring."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify cache backend reachability before enabling population\n// e.g. check memcached host connectivity at startup","typeGuard":null,"tryCatchPattern":"try { cache.put(key, bytes); } catch (Exception e) { log.warn(e, \"Could not populate cache\"); stats.incrementError(); }","preventionTips":["Keep cache entries under configured size limits","Monitor cachePopulator error metrics","Validate cache host config before rollout"],"tags":["druid","cache","background-population"],"backgroundTag":"database-write-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}