redis/jedis · error · JedisValidationException

Endpoint already exists in the provider

Error message

Endpoint ${endpoint} already exists in the provider

What it means

add(DatabaseConfig) rejects a configuration whose endpoint is already present in the provider's databaseMap. Each endpoint can be registered only once; duplicates would corrupt the failover topology, so a JedisValidationException naming the endpoint is thrown.

Solutions

  1. Check provider existence before adding: track registered endpoints or query the provider's state and skip duplicates.
  2. Deduplicate endpoint entries in your configuration source before registering.
  3. Catch JedisValidationException and treat 'already exists' as a no-op if idempotency is desired.

Example fix

// before
provider.add(cfg); // throws if endpoint already registered

// after
if (!registeredEndpoints.contains(cfg.getEndpoint())) {
  provider.add(cfg);
  registeredEndpoints.add(cfg.getEndpoint());
}
Defensive patterns

Strategy: validation

Validate before calling

if (!registeredEndpoints.contains(cfg.getEndpoint())) {
  provider.add(cfg);
  registeredEndpoints.add(cfg.getEndpoint());
}

Try / catch

try {
  provider.add(cfg);
} catch (JedisValidationException e) {
  if (e.getMessage().contains("already exists")) {
    // idempotent no-op
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Calling provider.add(config) twice with the same Endpoint; re-running initialization code that registers databases without checking existing entries.

Common situations: Application restart/reconnect logic that re-adds all configured databases to a live provider; retrying a failed add that actually succeeded; config files listing the same host:port twice.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/3fa26d28f6134143. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java:242

      builder.ignoreExceptions(ignoreExceptions.stream().toArray(Class[]::new));
    }

    return builder.build();
  }

  /**
   * Adds a new database endpoint to the provider.
   * @param databaseConfig the configuration for the new database
   * @throws JedisValidationException if the endpoint already exists
   */
  public void add(DatabaseConfig databaseConfig) {
    if (databaseConfig == null) {
      throw new JedisValidationException("DatabaseConfig must not be null");
    }

    Endpoint endpoint = databaseConfig.getEndpoint();
    if (databaseMap.containsKey(endpoint)) {
      throw new JedisValidationException(
          "Endpoint " + endpoint + " already exists in the provider");
    }

    activeDatabaseChangeLock.lock();
    try {
      addDatabaseInternal(multiDbConfig, databaseConfig);
    } finally {
      activeDatabaseChangeLock.unlock();
    }
  }

  /**
   * Removes a database endpoint from the provider.
   * @param endpoint the endpoint to remove
   * @throws JedisValidationException if the endpoint doesn't exist or is the last remaining
   *           endpoint
   */
  public void remove(Endpoint endpoint) {

View on GitHub (pinned to 6dac31d4c2)