You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to explicitly close DB connections?
There seems to be lazy-init="true" that helps when doing something else before the DB operations, but the same problem still remains after the DB operations :(.
What you can do is to create another etl.xml file to execute based on certain conditions after the other one with the DB operations (in case it does not depend on query logic).
Of course, this is quite annoying since it does not allow to logically group operations, and the logic is moved from the etl.xml to the shell file starting Scriptella, and also reduces the scenarios where Scriptella can be used.
Has any thought been given to allowing "include" to be a top level element so that you can include etl files, or creating a new element to allow including of sub etls? That way there would be a boundary around which Scriptella could automatically open / close declared connections.
I could give it a shot if anyone else thinks it's a good idea. I found the most confusing thing about Scriptella to be that there did not seem to be a way to break apart my ETL scripts into smaller (and more maintainable) chunks.
I did wind up breaking them apart anyway, but I'm using a wildcard in the launcher which does not typically have a guaranteed call order and therefore seems kinda code-smellish to me.
For testing something I actually made some changes based on version 1.2 allowing closing connections early. Probably I will ask to merge my changes to the trunk, if there is interest in that. It is quite simple and does not break the concepts.
@trombosestrumpf I no longer use this project, but scoping everything globally or heavy reliance on globally scoped variables is in general a bad practice and is one of the biggest categorical causes of software defects. I would assume if includes were added that you would add more / better scopes at the same time.
I don't remember much about it unfortunately as this thread was dormant for so long and I no longer remember any of the details.
It was useful when I was using it, but it was a former employer that was using it and I wouldn't be shocked to find that they too have moved on from it. But I could be wrong.
After eleven years, this might be a contender for the slowest fix ever 🙂 I’ve finally found time to return to working on Scriptella this year, and I’m targeting this enhancement for 1.7.
The scope is to allow explicitly closing a connection once its work is complete, while the remaining ETL continues. We’ll need clear semantics for pending transactions, active queries, and subsequent references to a closed connection.
The implementation will define how pending transactions are handled, prevent closure while a query is still using the connection, and provide clear behavior when a later script references a closed connection. Final cleanup will also account for connections that have already been closed.
Sub-ETL inclusion is outside the scope of this change.
Implemented in 73b0138 for the upcoming 1.7.0 release; not yet released.
The delivered interface is opt-in automatic closure after final use, rather than an explicit close command: connection property close.after.use, execution-wide default scriptella.close.after.use, built-in default false. Explicit connection settings override the global default.
Conservative analysis retires connections after their final potentially referencing top-level subtree completes, including nested queries, inherited references and error handlers. Owned new-tx connections are handled together; unopened lazy connections remain unopened. Statistics and progress counters survive retirement, and retired connections cannot reopen.
Enabling this feature introduces an early commit boundary: pending work is committed before closure, and later ETL failure/cancellation cannot roll it back. Default lifecycle behavior is unchanged.
Focused tests cover configuration precedence, repeated/nested execution, lazy/new-tx connections, failure/cancellation, commit failures, final JDBC batches, retained counters and conditional elements. Maven and Ant regression suites passed locally; CI passed on the implementation commit.
Repository documentation: docs/connection-lifecycle.md. Public website guide/reference publication, release notes and link verification are tracked in #70. Closing as implemented while retaining the 1.7.0 milestone.
Activity
aadrian commentedon May 30, 2015
I haven't found a way to achieve this :(.
What you can do is to create another
etl.xmlfile to execute based on certain conditions after the other one with the DB operations (in case it does not depend on query logic).Of course, this is quite annoying since it does not allow to logically group operations, and the logic is moved from the
etl.xmlto the shell file starting Scriptella, and also reduces the scenarios where Scriptella can be used.mrdanpsmith commentedon Jun 10, 2015
Has any thought been given to allowing "include" to be a top level element so that you can include etl files, or creating a new element to allow including of sub etls? That way there would be a boundary around which Scriptella could automatically open / close declared connections.
I could give it a shot if anyone else thinks it's a good idea. I found the most confusing thing about Scriptella to be that there did not seem to be a way to break apart my ETL scripts into smaller (and more maintainable) chunks.
I did wind up breaking them apart anyway, but I'm using a wildcard in the launcher which does not typically have a guaranteed call order and therefore seems kinda code-smellish to me.
trombosestrumpf commentedon Feb 14, 2022
For testing something I actually made some changes based on version 1.2 allowing closing connections early. Probably I will ask to merge my changes to the trunk, if there is interest in that. It is quite simple and does not break the concepts.
trombosestrumpf commentedon Feb 14, 2022
@mrdanpsmith
Breaking ETL scripts into chunks could be problematic for the scope of ETL variables, and a lot of other referencing stuff i am afraid.
mrdanpsmith commentedon Feb 14, 2022
@trombosestrumpf I no longer use this project, but scoping everything globally or heavy reliance on globally scoped variables is in general a bad practice and is one of the biggest categorical causes of software defects. I would assume if includes were added that you would add more / better scopes at the same time.
I don't remember much about it unfortunately as this thread was dormant for so long and I no longer remember any of the details.
It was useful when I was using it, but it was a former employer that was using it and I wouldn't be shocked to find that they too have moved on from it. But I could be wrong.
Cheers!
ejboy commentedon Oct 21, 2026
After eleven years, this might be a contender for the slowest fix ever 🙂 I’ve finally found time to return to working on Scriptella this year, and I’m targeting this enhancement for 1.7.
The scope is to allow explicitly closing a connection once its work is complete, while the remaining ETL continues. We’ll need clear semantics for pending transactions, active queries, and subsequent references to a closed connection.
The implementation will define how pending transactions are handled, prevent closure while a query is still using the connection, and provide clear behavior when a later script references a closed connection. Final cleanup will also account for connections that have already been closed.
Sub-ETL inclusion is outside the scope of this change.
Add optional connection closure after final use (#19)
ejboy commentedon Oct 25, 2026
Implemented in 73b0138 for the upcoming 1.7.0 release; not yet released.
The delivered interface is opt-in automatic closure after final use, rather than an explicit close command: connection property
close.after.use, execution-wide defaultscriptella.close.after.use, built-in defaultfalse. Explicit connection settings override the global default.Conservative analysis retires connections after their final potentially referencing top-level subtree completes, including nested queries, inherited references and error handlers. Owned
new-txconnections are handled together; unopened lazy connections remain unopened. Statistics and progress counters survive retirement, and retired connections cannot reopen.Enabling this feature introduces an early commit boundary: pending work is committed before closure, and later ETL failure/cancellation cannot roll it back. Default lifecycle behavior is unchanged.
Focused tests cover configuration precedence, repeated/nested execution, lazy/new-tx connections, failure/cancellation, commit failures, final JDBC batches, retained counters and conditional elements. Maven and Ant regression suites passed locally; CI passed on the implementation commit.
Repository documentation:
docs/connection-lifecycle.md. Public website guide/reference publication, release notes and link verification are tracked in #70. Closing as implemented while retaining the 1.7.0 milestone.