{"record":{"id":"c6ff72419d64b63b","repo":"prestodb/presto","slug":"unexpected-accumulo-error-c6ff72","errorCode":"UNEXPECTED_ACCUMULO_ERROR","errorMessage":"Exception when getting cardinality","messagePattern":"Exception when getting cardinality","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"presto-accumulo/src/main/java/com/facebook/presto/accumulo/index/ColumnCardinalityCache.java","lineNumber":168,"sourceCode":"                    }\n                }\n\n                // If the smallest cardinality is present and below the threshold, set the earlyReturn flag\n                Optional<Entry<Long, AccumuloColumnConstraint>> smallestCardinality = cardinalityToConstraints.entries().stream().findFirst();\n                if (smallestCardinality.isPresent()) {\n                    if (smallestCardinality.get().getKey() <= earlyReturnThreshold) {\n                        LOG.info(\"Cardinality %s, is below threshold. Returning early while other tasks finish\", smallestCardinality);\n                        earlyReturn = true;\n                    }\n                }\n            }\n            while (!earlyReturn && cardinalityToConstraints.entries().size() < numTasks);\n        }\n        catch (ExecutionException | InterruptedException e) {\n            if (e instanceof InterruptedException) {\n                Thread.currentThread().interrupt();\n            }\n            throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, \"Exception when getting cardinality\", e);\n        }\n\n        // Create a copy of the cardinalities\n        return ImmutableMultimap.copyOf(cardinalityToConstraints);\n    }\n\n    /**\n     * Gets the column cardinality for all of the given range values. May reach out to the\n     * metrics table in Accumulo to retrieve new cache elements.\n     *\n     * @param schema Table schema\n     * @param table Table name\n     * @param auths Scan authorizations\n     * @param family Accumulo column family\n     * @param qualifier Accumulo column qualifier\n     * @param colValues All range values to summarize for the cardinality\n     * @return The cardinality of the column\n     */","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-accumulo/src/main/java/com/facebook/presto/accumulo/index/ColumnCardinalityCache.java#L150-L186","documentation":"ColumnCardinalityCache.getCardinalities fans out several concurrent range-count tasks against the Accumulo metrics table and joins them via futures; this catch-all wraps any ExecutionException or InterruptedException from that join into UNEXPECTED_ACCUMULO_ERROR. It means an underlying cardinality computation failed for a reason the connector does not classify more precisely.","triggerScenarios":"One or more concurrent range-scan tasks against the metrics table failed (Accumulo client error, scanner timeout, tablet server loss), or the thread waiting on the futures was interrupted by query cancellation or shutdown.","commonSituations":"Accumulo tablet server restart or timeout during a query using index cardinalities; scanner timeouts on the metrics table; user cancelling the Presto query mid-scan (interrupt); network instability between Presto workers and Accumulo.","solutions":["Inspect the wrapped cause (the PrestoException carries the original ExecutionException) to find the real Accumulo/network failure and fix that.","Retry the query - transient tablet-server or scanner failures often resolve on their own.","Check the Accumulo monitor and logs for errors on the metrics table around the failure time.","If the cause is InterruptedException, avoid cancelling the query or address coordinator/worker shutdown during scans.","Increase scanner/timeout settings if scans against the metrics table are timing out."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    multimap = cache.getCardinalities(constraints);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"UNEXPECTED_ACCUMULO_ERROR\")) {\n        if (e.getCause() instanceof InterruptedException) {\n            Thread.currentThread().interrupt(); // honor cancellation\n        }\n        // inspect e.getCause() for the real Accumulo failure; retry transient errors\n    } else {\n        throw e;\n    }\n}","preventionTips":["Retry queries that fail with this error once - many causes are transient Accumulo/timeout issues.","Monitor Accumulo tablet-server health; restarts commonly interrupt cardinality scans.","Avoid cancelling queries mid-scan; interrupts surface as this error.","Check the wrapped cause in logs to distinguish timeouts from genuine Accumulo faults."],"tags":["accumulo","cache","concurrency","cardinality","index"],"backgroundTag":"unexpected-storage-error","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}