{"record":{"id":"fe96e498db7b314a","repo":"apache/shardingsphere","slug":"rollback-savepoint","errorCode":null,"errorMessage":"rollback savepoint","messagePattern":"rollback savepoint","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/state/circuit/connection/CircuitBreakerConnection.java","lineNumber":109,"sourceCode":"    public void setAutoCommit(final boolean autoCommit) {\n    }\n    \n    @Override\n    public boolean getAutoCommit() {\n        return false;\n    }\n    \n    @Override\n    public void commit() {\n    }\n    \n    @Override\n    public void rollback() {\n    }\n    \n    @Override\n    public void rollback(final Savepoint savepoint) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"rollback savepoint\");\n    }\n    \n    @Override\n    public Savepoint setSavepoint() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setSavepoint\");\n    }\n    \n    @Override\n    public Savepoint setSavepoint(final String name) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setSavepoint name\");\n    }\n    \n    @Override\n    public void releaseSavepoint(final Savepoint savepoint) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"releaseSavepoint\");\n    }\n    \n    @Override","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/state/circuit/connection/CircuitBreakerConnection.java#L91-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove or disable nested transactions / savepoint usage (e.g. avoid PROPAGATION_NESTED) for connections that may be circuit-broken.","Restore the underlying database connectivity so the circuit breaker closes and a real Connection with savepoint support is returned.","Check the data source's circuit-breaker/lock state (ShardingSphereDriverConnection state objects) before beginning savepoint-dependent logic.","Catch SQLFeatureNotSupportedException and degrade the operation to a full rollback()."],"exampleFix":"// before\nSavepoint sp = conn.setSavepoint();\n... \nconn.rollback(sp);\n\n// after (avoid savepoints on ShardingSphere connections)\nif (connection.getMetaData().supportsSavepoints()) {\n    Savepoint sp = conn.setSavepoint();\n    try { ... } finally { conn.rollback(sp); }\n} else {\n    conn.rollback(); // full rollback fallback\n}","handlingStrategy":"validation","validationCode":"boolean savepointsSafe = false;\ntry {\n    savepointsSafe = conn.getMetaData().supportsSavepoints()\n            && !(conn.isClosed());\n} catch (final SQLException ignored) { }\nif (!savepointsSafe) { /* skip savepoint rollback, use full rollback */ }","typeGuard":null,"tryCatchPattern":"try {\n    conn.rollback(sp);\n} catch (final SQLFeatureNotSupportedException ex) {\n    conn.rollback(); // circuit-broken connection: full rollback is a no-op but safe\n}","preventionTips":["Avoid PROPAGATION_NESTED / JDBC savepoints in services that must keep running through database failover.","Monitor the data source's circuit-breaker state and shed savepoint-dependent work while OPEN.","Null-check Savepoints and remember setSavepoint threw before attempting rollback/release."],"tags":["jdbc","circuit-breaker","savepoint","transaction"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}