[BulkInsert] Will it leak database connection when encounter error?
Service icon
Forge component by Galter
Application Type

After checking bulkinsert source code, I found that we didn't call IDbConnection.Close in finally block. 

Recently Our server is done due to db connection pool exhausted.  

BulkInsert use the Main Transaction of HTTP Request.(just like Aggregate / Advance SQL)
So we NEED NOT commit / rollback or close db connection. 
Because OutSystems will commit and close db connection when Request finished.

According to the exception message [string or binary would be truncated]
The root cause is quite simple.
You had some text attributes, but value of your data had exceed the max length of attribute.
So you need check and find the attribute value that caused this error.
And then change the max length of related attribute.


Yes, we are fixing the root cause. 

My concern is that if we use bulkinsert in a light process,  is it still true that we need not to close?

I had reviewed the source code.

It seems the issue is it should use [C# using clause] for RequestTransaction.
This is recommended by OutSystems as following sample.

But you still should not close dbconnection because you had active transaction that managed by OutSystems.
If you close dbconnection , it will cause unexpected behaviour.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.