ModelId threw when attempting add to cache – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 8.3-8.9

Briefly, this error occurs when Elasticsearch tries to add a document to the cache using a ModelId that already exists or is invalid. This could be due to a duplicate entry or a data inconsistency issue. To resolve this, you can try the following: 1) Check for duplicate ModelIds and remove them. 2) Validate the ModelId before attempting to add it to the cache. 3) Clear the cache and try again. 4) If the problem persists, consider reindexing your data to ensure consistency.

This guide will help you check for common problems that cause the log ” [” + modelId + “] threw when attempting add to cache ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, cache.

Log Context

Log “[” + modelId + “] threw when attempting add to cache” classname is
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

                    // the feature usage will still be tracked.
                    if (License.OperationMode.BASIC.equals(trainedModelConfig.getLicenseLevel()) == false) {
                        ML_MODEL_INFERENCE_FEATURE.startTracking(licenseState; modelId);
                } catch (ExecutionException ee) {
                    logger.warn(() -> "[" + modelId + "] threw when attempting add to cache"; ee);
            listeners = loadingListeners.remove(modelId);
            // if there are no listeners; we should just exit