pentaho/pentaho-kettle · error · IOException

Port to close was not found in the Carte socket repository!

Error message

Port to close was not found in the Carte socket repository!

What it means

SocketRepository.releaseSocket(port) marks a previously allocated port free, but if socketMap has no entry for that port it throws IOException("Port to close was not found in the Carte socket repository!"). It means code tried to release a port that was never allocated through this SocketRepository instance (or the repository was reset).

Solutions

  1. Only release ports that were successfully allocated via the same SocketRepository; guard the release call with the allocation result.
  2. Make release idempotent: check the entry/port exists before releasing instead of treating absence as an error.
  3. Trace which port number is being released; ensure the clustered transformation's slave server config matches the one that allocated it.
  4. If caused by a double-release in cleanup code, add a flag so the release runs once.

Example fix

// before: releases even when allocation failed
int port = socketRepository.allocateServerSocketPort(...);
... // if allocation threw, finally still runs
finally { socketRepository.releaseSocket(port); }

// after: only release what was allocated
int port = -1;
try {
  port = socketRepository.allocateServerSocketPort(...);
  ...
} finally {
  if (port >= 0) socketRepository.releaseSocket(port);
}
Defensive patterns

Strategy: validation

Validate before calling

if (port >= 0 && socketWasAllocated(port)) {
  socketRepository.releaseSocket(port);
}

Try / catch

try {
  socketRepository.releaseSocket(port);
} catch (IOException e) {
  if (e.getMessage().contains("not found")) {
    log.debug("Port {} already released or never allocated; ignoring", port); // make cleanup idempotent
  } else throw e;
}

Prevention

When it happens

Trigger: Calling releaseSocket(port) with a port outside the repository's allocated range, releasing twice for the same allocation after the entry was removed, or releasing on a different Carte SocketRepository instance than the one that allocated the port.

Common situations: Custom transformation code closing sockets in a finally block that runs even when allocation failed; cleanup logic in clustered transformations running on the wrong slave node; bookkeeping mismatch after Carte re-created its socket map (restart) while clients still hold old port numbers.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/008efce645c72486. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/www/SocketRepository.java:131

        entry.setServerSocket( createServerSocket( port ) );
      }
      entry.setInUse( true );
    }

    return entry.getServerSocket();
  }

  /**
   * We don't actually ever close a server socket, we re-use them as much as possible.
   *
   * @param port
   * @throws IOException
   */
  public synchronized void releaseSocket( int port ) throws IOException {

    SocketRepositoryEntry entry = socketMap.get( port );
    if ( entry == null ) {
      throw new IOException( "Port to close was not found in the Carte socket repository!" );
    }
    entry.setInUse( false );
  }

  /**
   * @return the socketMap
   */
  public Map<Integer, SocketRepositoryEntry> getSocketMap() {
    return socketMap;
  }

  /**
   * @param socketMap
   *          the socketMap to set
   */
  public void setSocketMap( Map<Integer, SocketRepositoryEntry> socketMap ) {
    this.socketMap = socketMap;
  }

View on GitHub (pinned to f3058517a1)