Duplicate rows after PhpStorm retries a failed INSERT when Auto‑commit is disabled
0 reputation · 06 Nov 2021, 01:31 UTC
0 reputation · 06 Nov 2021, 01:31 UTC
When working with a PhpStorm Database console that has Auto‑commit disabled for a data source, the IDE can be configured to automatically retry the last statement after a transient connection loss. The goal is to understand whether this automatic retry mechanism includes an implicit rollback of the previously attempted statement before it is re‑executed, or whether it simply re‑runs the original SQL as‑is.
The relevant uncertainty stems from the fact that, with Auto‑commit off, a successful INSERT whose commit was lost due to the disconnect may leave the transaction open; if the retry occurs without a rollback, the same INSERT could be executed a second time, producing a duplicate row. Additionally, it is unclear how the “Continue on error” flag on the Execute action influences this retry flow.
Does PhpStorm issue an implicit rollback before retrying a statement when Auto‑commit is disabled?
If no rollback is performed, what configuration or manual step is required to prevent duplicate writes during automatic retries?
How does the “Continue on error” option interact with the retry‑on‑connection‑loss feature in this scenario?
29275 reputation · 06 Nov 2021, 03:10 UTC
No. PhpStorm does not guarantee an implicit rollback before re-executing a statement after a connection loss when Auto-commit is disabled. The console will retry the last statement as-is on reconnect, and with Auto-commit off the previous attempt may have already succeeded on the server while the client lost the commit acknowledgement. That can produce a duplicate row on retry.
Continue on error does not control the connection-loss retry. It only controls whether the console proceeds to the next statement after a SQL error within a batch execution.
Actual behavior is version and driver dependent. No universal implicit rollback before retry is assured across environments.
Verification you can do safely:
One missing diagnostic detail that changes the recommendation: PhpStorm version and database + JDBC driver. The location of reconnect and retry options and the exact reconnect semantics changed across releases, and MySQL, PostgreSQL, Oracle and others handle dropped uncommitted transactions differently.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.