apache/seatunnel · error · IOException

Connection pool error.

Error message

Connection pool error.

What it means

getFromPool throws this IOException when the pool finds an idleConnections entry whose Set is empty (size 0) but non-null — an internal inconsistency, since idle channels should have been removed together with their empty set. It signals corrupted pool bookkeeping.

Source

Thrown at seatunnel-connectors-v2/connector-file/connector-file-sftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sftp/system/SFTPConnectionPool.java:74

    synchronized ChannelSftp getFromPool(ConnectionInfo info) throws IOException {
        if (con2infoMap == null) {
            throw new IOException("SFTP connection pool has been closed.");
        }
        Set<ChannelSftp> cons = idleConnections.get(info);
        ChannelSftp channel;

        if (cons != null && cons.size() > 0) {
            Iterator<ChannelSftp> it = cons.iterator();
            if (it.hasNext()) {
                channel = it.next();
                it.remove();
                if (cons.isEmpty()) {
                    idleConnections.remove(info);
                }
                return channel;
            } else {
                throw new IOException("Connection pool error.");
            }
        }
        return null;
    }

    synchronized boolean returnToPool(ChannelSftp channel) {
        if (con2infoMap == null) {
            return false;
        }
        ConnectionInfo info = con2infoMap.get(channel);
        if (info == null) {
            return false;
        }
        HashSet<ChannelSftp> cons = idleConnections.get(info);
        if (cons == null) {
            cons = new HashSet<ChannelSftp>();
            idleConnections.put(info, cons);
        }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. This indicates a library-internal bug: report it / upgrade the connector version where pool bookkeeping is fixed
  2. Recycle the SFTPFileSystem/pool: close it and create a new one to clear corrupted state
  3. Retry the operation with a fresh filesystem instance

Example fix

// before
SFTPFileSystem fs = cachedFs; // pool state corrupted
// after
cachedFs.close();
SFTPFileSystem fs = (SFTPFileSystem) FileSystem.get(uri, conf); // fresh pool
Defensive patterns

Strategy: retry

Try / catch

try {
    pool.getFromPool(info);
} catch (IOException e) {
    if ("Connection pool error.".equals(e.getMessage())) {
        recreateFileSystem(); // pool bookkeeping corrupted; start fresh
    } else throw e;
}

Prevention

When it happens

Trigger: An idleConnections map entry exists for the ConnectionInfo key but its channel set is empty when getFromPool iterates it; the else branch fires and throws. This is effectively an internal invariant violation inside SFTPConnectionPool.

Common situations: Rare; typically seen under concurrent mutation of pool state if synchronization assumptions are broken, or after abnormal channel return/removal sequences leaving an empty set registered.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/e22a946aa052320b. Report an issue: GitHub.