prestodb/presto · error · IllegalArgumentException
Query Prerequisites '%s' is already registered
Error message
Query Prerequisites '%s' is already registered
What it means
ConfidenceBasedClusterTtlProviderManager.addClusterTtlProviderFactory throws IllegalArgumentException when a ClusterTtlProviderFactory whose getName() is already present in the clusterTtlProviderFactories map is registered again (putIfAbsent returns non-null). Factory names must be unique within the manager.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/ttl/clusterttlprovidermanagers/ConfidenceBasedClusterTtlProviderManager.java:68
@Inject
public ConfidenceBasedClusterTtlProviderManager(NodeTtlFetcherManager nodeTtlFetcherManager)
{
this.nodeTtlFetcherManager = requireNonNull(nodeTtlFetcherManager, "nodeTtlFetcherManager is null");
}
@Override
public ConfidenceBasedTtlInfo getClusterTtl()
{
return clusterTtlProvider.get().getClusterTtl(ImmutableList.copyOf(nodeTtlFetcherManager.getAllTtls().values()));
}
@Override
public void addClusterTtlProviderFactory(ClusterTtlProviderFactory clusterTtlProviderFactory)
{
requireNonNull(clusterTtlProviderFactory, "clusterTtlProviderFactory is null");
if (clusterTtlProviderFactories.putIfAbsent(clusterTtlProviderFactory.getName(), clusterTtlProviderFactory) != null) {
throw new IllegalArgumentException(format("Query Prerequisites '%s' is already registered", clusterTtlProviderFactory.getName()));
}
}
@Override
public void loadClusterTtlProvider()
throws Exception
{
if (Files.exists(CLUSTER_TTL_PROVIDER_CONFIG)) {
Map<String, String> properties = new HashMap<>(loadProperties(CLUSTER_TTL_PROVIDER_CONFIG.toFile()));
String factoryName = properties.remove(CLUSTER_TTL_PROVIDER_PROPERTY_NAME);
checkArgument(!isNullOrEmpty(factoryName),
"Cluster Ttl Provider configuration %s does not contain %s", CLUSTER_TTL_PROVIDER_CONFIG.toAbsolutePath(), CLUSTER_TTL_PROVIDER_PROPERTY_NAME);
load(factoryName, properties);
}
else {
load("infinite", ImmutableMap.of());
}View on GitHub (pinned to 55bb57d202)
Solutions
- Remove duplicate plugin jars so the factory is only loaded once.
- Rename one factory's getName() to a unique value.
- Guard registration: check clusterTtlProviderFactories contains the name before adding.
- Create a fresh manager instance per test/setup instead of reusing it.
Example fix
// before
manager.addClusterTtlProviderFactory(new MyTtlProviderFactory("confidence"));
manager.addClusterTtlProviderFactory(new OtherFactory("confidence")); // duplicate
// after
String name = "my-unique-ttl-provider";
if (manager.getClusterTtlProviderFactories().stream().noneMatch(f -> f.getName().equals(name))) {
manager.addClusterTtlProviderFactory(new MyTtlProviderFactory(name));
} Defensive patterns
Strategy: try-catch
Validate before calling
// Check for existing factory with same name before registering
boolean exists = manager.getClusterTtlProviderFactories().stream()
.anyMatch(f -> f.getName().equals(newFactory.getName()));
if (exists) {
// skip registration or fail with a clear duplicate error
} Type guard
boolean isFactoryNameFree(ClusterTtlProviderManager m, String name) {
return m.getClusterTtlProviderFactories().stream().noneMatch(f -> f.getName().equals(name));
} Try / catch
try {
manager.addClusterTtlProviderFactory(factory);
} catch (IllegalArgumentException e) {
LOG.warn("TTL provider factory '%s' already registered; ignoring duplicate", factory.getName());
} Prevention
- Keep only one copy of each plugin jar on the plugin path.
- Use unique, namespaced factory names across plugins.
- Make plugin setup idempotent (skip already-registered factories).
- In tests, create a fresh manager per setup rather than reusing instances.
When it happens
Trigger: Calling addClusterTtlProviderFactory twice with factories sharing the same name — typically re-running plugin setup, loading two plugin versions that both register the same TTL provider factory name, or a plugin registering a name that collides with a built-in factory.
Common situations: See trigger scenarios.
Related errors
- Node ttl fetcher factory '%s' is already registered
- NODE_SELECTION_NOT_SUPPORTED
- NO_NODES_AVAILABLE
- ALREADY_EXISTS
- FUNCTION_IMPLEMENTATION_MISSING
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/af6ed2641da89471.
Report an issue: GitHub.