apache/shardingsphere · error · SQLFeatureNotSupportedException

rollback savepoint

Error message

rollback savepoint

What it means

CircuitBreakerConnection is the Connection implementation returned while the underlying ShardingSphere data source is in OPEN (circuit-broken) state. Read/write and transaction-end calls are made harmless no-ops (commit() and rollback() do nothing), but savepoint operations cannot be safely faked, so rollback(Savepoint) throws SQLFeatureNotSupportedException("rollback savepoint"). The failure indicates your code touched savepoints while the backend was unavailable.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/state/circuit/connection/CircuitBreakerConnection.java:109

    public void setAutoCommit(final boolean autoCommit) {
    }
    
    @Override
    public boolean getAutoCommit() {
        return false;
    }
    
    @Override
    public void commit() {
    }
    
    @Override
    public void rollback() {
    }
    
    @Override
    public void rollback(final Savepoint savepoint) throws SQLException {
        throw new SQLFeatureNotSupportedException("rollback savepoint");
    }
    
    @Override
    public Savepoint setSavepoint() throws SQLException {
        throw new SQLFeatureNotSupportedException("setSavepoint");
    }
    
    @Override
    public Savepoint setSavepoint(final String name) throws SQLException {
        throw new SQLFeatureNotSupportedException("setSavepoint name");
    }
    
    @Override
    public void releaseSavepoint(final Savepoint savepoint) throws SQLException {
        throw new SQLFeatureNotSupportedException("releaseSavepoint");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Remove or disable nested transactions / savepoint usage (e.g. avoid PROPAGATION_NESTED) for connections that may be circuit-broken.
  2. Restore the underlying database connectivity so the circuit breaker closes and a real Connection with savepoint support is returned.
  3. Check the data source's circuit-breaker/lock state (ShardingSphereDriverConnection state objects) before beginning savepoint-dependent logic.
  4. Catch SQLFeatureNotSupportedException and degrade the operation to a full rollback().

Example fix

// before
Savepoint sp = conn.setSavepoint();
... 
conn.rollback(sp);

// after (avoid savepoints on ShardingSphere connections)
if (connection.getMetaData().supportsSavepoints()) {
    Savepoint sp = conn.setSavepoint();
    try { ... } finally { conn.rollback(sp); }
} else {
    conn.rollback(); // full rollback fallback
}
Defensive patterns

Strategy: validation

Validate before calling

boolean savepointsSafe = false;
try {
    savepointsSafe = conn.getMetaData().supportsSavepoints()
            && !(conn.isClosed());
} catch (final SQLException ignored) { }
if (!savepointsSafe) { /* skip savepoint rollback, use full rollback */ }

Try / catch

try {
    conn.rollback(sp);
} catch (final SQLFeatureNotSupportedException ex) {
    conn.rollback(); // circuit-broken connection: full rollback is a no-op but safe
}

Prevention

When it happens

Trigger: The data source's circuit breaker has tripped (all real connections closed); application code that previously did setSavepoint() then calls conn.rollback(savepoint) on the circuit-broken Connection.

Common situations: Database outage or failover triggers the circuit breaker while an application with savepoint-based partial-rollback logic is running; connection-pool validation code exercising all Connection methods; a Spring @Transactional flow with PROPAGATION_NESTED, which maps to JDBC savepoints.

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/fe96e498db7b314a. Report an issue: GitHub.