alibaba/nacos · critical · NacosApiException

30000

30000

Error message

Meta cas failed

What it means

Thrown by handleStrictCasResult when doCasLoop returns CasResult.META_LOST — the resource meta row disappeared (became null or lost its metaVersion) during a retry iteration of the optimistic CAS loop. HTTP 500 SERVER_ERROR (code 30000). This indicates the resource was deleted concurrently while being updated.

Source

Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/resource/AiResourceManager.java:151

                newValue)) {
                return CasResult.SUCCESS;
            }
            AiResource latest = aiResourcePersistService.find(namespaceId, name, type);
            if (latest == null || latest.getMetaVersion() == null) {
                return CasResult.META_LOST;
            }
            expected = latest.getMetaVersion();
            onConflictRefresh.accept(newValue, latest);
        }
        return CasResult.MAX_RETRIES;
    }
    
    /**
     * Translate a non-SUCCESS CasResult into the appropriate exception for strict callers.
     */
    private void handleStrictCasResult(CasResult result) throws NacosException {
        if (result == CasResult.META_LOST) {
            throw new NacosApiException(NacosException.SERVER_ERROR, ErrorCode.SERVER_ERROR,
                "Meta cas failed");
        }
        if (result == CasResult.MAX_RETRIES) {
            throw new NacosApiException(NacosException.CONFLICT, ErrorCode.RESOURCE_CONFLICT,
                "Meta update conflict, retry");
        }
    }
    
    /**
     * CAS-update the versionInfo field of a resource meta row.
     */
    public void updateVersionInfoCas(String namespaceId, AiResource meta, ResourceVersionInfo info)
        throws NacosException {
        if (meta == null || meta.getMetaVersion() == null) {
            throw new NacosApiException(NacosException.SERVER_ERROR, ErrorCode.SERVER_ERROR,
                "Meta version missing");
        }
        AiResource newValue = buildVersionInfoUpdateValue(meta, info);

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Verify the resource still exists before retrying the operation.
  2. Investigate and eliminate concurrent delete operations on resources being updated.
  3. If using a reaper/cleanup job, ensure it does not race with active mutations.
  4. Reload the resource and retry the full operation if the delete was unintended.

Example fix

// before: update races with a concurrent delete
resourceManager.updateBizTagsCas(ns, meta, newTags); // meta deleted mid-loop

// after: check existence, retry the whole operation
AiResource fresh = resourceManager.findMeta(ns, name, type);
if (fresh != null) {
    resourceManager.updateBizTagsCas(ns, fresh, newTags);
}
Defensive patterns

Strategy: retry

Validate before calling

// Verify resource exists before CAS update
AiResource meta = resourceManager.findMeta(ns, name, type);
if (meta == null) {
    // resource was deleted — abort or recreate
    return;
}

Type guard

boolean resourceAlive = resourceManager.findMeta(ns, name, type) != null;

Try / catch

try {
    resourceManager.updateBizTagsCas(ns, meta, tags);
} catch (NacosApiException e) {
    if (e.getErrCode() == NacosException.SERVER_ERROR
        && e.getMessage().contains("Meta cas failed")) {
        // resource deleted mid-update — check if intentional, reload or abort
    }
    throw e;
}

Prevention

When it happens

Trigger: A CAS-based meta update (versionInfo, bizTags, description) is in its retry loop, and between a failed updateMetaCas and the subsequent find(), the resource is deleted. The retry re-fetch returns null, triggering META_LOST which handleStrictCasResult translates to this exception.

Common situations: Concurrent delete and update on the same resource; a cleanup/reaper process removes resources while a write is in-flight; manual database intervention deleting rows during active traffic.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/49c3c851073c2a3c. Report an issue: GitHub.