ORA-01013: SQL Developer does not automatically rollback after query cancellation
0 reputation · 24 Feb 2020, 09:45 UTC
0 reputation · 24 Feb 2020, 09:45 UTC
When a long‑running query is stopped in Oracle SQL Developer via the worksheet stop button, the database returns the ORA‑01013 error. However, the transaction that was in progress remains active, holding locks until a manual COMMIT or ROLLBACK is issued.
SQL Developer does not expose a UI setting to automatically roll back after a cancellation. The behavior has been observed in multiple releases (e.g., 21.x and 23.x) and may vary with the JDBC driver and database version. Because the transaction stays open, subsequent statements can be blocked by stale locks.
29275 reputation · 24 Feb 2020, 11:50 UTC
When you press the stop button in an Oracle SQL Developer worksheet, the client sends a cancel request to the server. Oracle Database responds with ORA-01013: user requested cancel of current operation. The cancellation only aborts the currently executing statement; it does not affect the transaction state. If autocommit is disabled, any INSERT/UPDATE/DELETE that was part of an open transaction remains active, holding locks until you issue an explicit COMMIT or ROLLBACK.
Tools → Preferences → Database → Autocommit.Auto Commit is checked.Auto Commit box.OK to save.ROLLBACK;
Ctrl+Enter).SELECT sid, serial#, status, taddr FROM v$session WHERE username = USER;
TADDR is NULL, no transaction is active.SELECT * FROM v$lock WHERE sid = (SELECT sid FROM v$session WHERE username = USER);
If you are using a custom connection plugin or a non‑standard JDBC driver that might override autocommit behavior, let me know the exact driver version and connection properties so I can confirm whether the above steps apply.
Use comments to ask for clarification. Post a solution as an answer.
29,275 reputation · 24 Feb 2020, 10:05 UTC
After a worksheet stop triggers ORA‑01013, the session stays open. You can confirm this with a quick query:
SELECT sid, serial#, status, state
FROM v$session
WHERE username = USER AND state = 'ACTIVE';
If the session appears, the transaction is still active. You can then issue:
ROLLBACK;
or, if you prefer to end it automatically, create a small script that checks V$TRANSACTION and rolls back any session whose STATE is ACTIVE.
Canceling a DML inside a PL/SQL block aborts the block but does not commit or rollback; the transaction remains open until you explicitly roll it back.
Enabling Auto Commit via Tools → Preferences → Database → Autocommit closes the transaction immediately after each statement, so a subsequent ORA‑01013 will not leave locks behind. Use this only if you do not need multi‑statement atomicity.