prestodb/presto · error · PrestoException

FUNCTION_IMPLEMENTATION_ERROR

FUNCTION_IMPLEMENTATION_ERROR

Error message

Scan for default tablet returned more than one entry

What it means

AccumuloClient.getDefaultTabletLocation scans the default tablet metadata row (range tableId + '<') and expects exactly one entry giving the tablet's location. If the scan returns two or more entries, the metadata does not match the expected single default tablet, which the connector treats as an internal implementation invariant violation, so it throws FUNCTION_IMPLEMENTATION_ERROR.

Source

Thrown at presto-accumulo/src/main/java/com/facebook/presto/accumulo/AccumuloClient.java:868

            return Optional.empty();
        }
    }

    private Optional<String> getDefaultTabletLocation(String fulltable)
    {
        try {
            String tableId = connector.tableOperations().tableIdMap().get(fulltable);

            // Create a scanner over the metadata table, fetching the 'loc' column of the default tablet row
            Scanner scan = connector.createScanner("accumulo.metadata", connector.securityOperations().getUserAuthorizations(username));
            scan.fetchColumnFamily(new Text("loc"));
            scan.setRange(new Range(tableId + '<'));

            // scan the entry
            Optional<String> location = Optional.empty();
            for (Entry<Key, Value> entry : scan) {
                if (location.isPresent()) {
                    throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, "Scan for default tablet returned more than one entry");
                }

                location = Optional.of(entry.getValue().toString());
            }

            scan.close();
            return location;
        }
        catch (Exception e) {
            // Swallow this exception so the query does not fail due to being unable to locate the tablet server for the default tablet.
            // This is purely an optimization, but we will want to log the error.
            LOG.error("Failed to get tablet location, returning dummy location", e);
            return Optional.empty();
        }
    }

    /**
     * Gets a collection of Accumulo Range objects from the given Presto domain.

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the accumulo.metadata table rows for the affected table ID (range starting at tableId + '<') and remove duplicate/stale entries.
  2. Verify table integrity with Accumulo's continuous ingest verification or 'accumulo check' tools; recreate the table from source data if metadata is unrecoverable.
  3. Re-create the Presto table (DROP/CREATE) so Accumulo rebuilds a clean default tablet entry.
  4. Check Accumulo server logs around the time of table creation for split/merge failures that may have produced extra rows.

Example fix

// After cleaning duplicate metadata rows in accumulo.metadata for tableId '5':
// verify only one entry remains
user@accumulo accumulo.metadata> scan -r '5<'
// if duplicates found, delete stale ones, then in Presto:
// SHOW TABLES FROM schema;  -- retries getTabletLocation successfully
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the metadata scan count before relying on the location:
try (Scanner meta = conn.createScanner("accumulo.metadata", Authorizations.EMPTY)) {
  meta.setRange(new Range(tableId + "<"));
  int count = 0;
  for (Entry<Key,Value> e : meta) if (++count > 1) throw new IllegalStateException("Multiple default tablet entries for " + tableId);
}

Try / catch

try {
  String loc = client.getDefaultTabletLocation(tableId);
} catch (PrestoException e) {
  if (e.getErrorCode().getCode() == StandardErrorCode.FUNCTION_IMPLEMENTATION_ERROR.toErrorCode().getCode()) {
    // inspect/clean accumulo.metadata rows for tableId, then retry or recreate table
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling getTabletLocation on a table whose metadata table contains more than one row in the range [tableId + '<') — i.e. multiple entries before the default tablet marker, typically caused by corrupted or manually modified Accumulo metadata entries for that table.

Common situations: Corrupted Accumulo metadata after failed compactions or split operations; rows manually inserted/edited in the accumulo.metadata table; stale duplicate metadata entries left over from table recovery or restore procedures.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/4dcc10b450266ff0. Report an issue: GitHub.