Home All Groups Group Topic Archive Search About

SQLBulkCopy WriteToServer timeout exception occassionally

Author
4 Nov 2005 3:46 PM
AdrianDams
I have a system that fills a DataTable and periodically sends it to the SQL
Server using SQLBulkCopy.WriteToServer. On the whole, the solution works
great, but very occassionally I get a timeout exception. I have set the
bulkcopy timout to 30 seconds which, for my data load, is plenty. Typically
the bulk compy completes inside of a second or two.

The SQL Server is on the local machine so  network conditions aren't
relevant, and the machine does not appear to have been overloaded at that
time. Nothing appears in the event log at any rate.

Has anyone else experienced the same sort of problem?

Adrian

Author
4 Nov 2005 8:38 PM
John Bell
Hi

I have not run into your problem, but you may want to profile the system
whilst you are running this and check for locking and blocking, also file
expansion may be an issue if they occur at the same time.

John

Show quote
"AdrianDams" wrote:

> I have a system that fills a DataTable and periodically sends it to the SQL
> Server using SQLBulkCopy.WriteToServer. On the whole, the solution works
> great, but very occassionally I get a timeout exception. I have set the
> bulkcopy timout to 30 seconds which, for my data load, is plenty. Typically
> the bulk compy completes inside of a second or two.
>
> The SQL Server is on the local machine so  network conditions aren't
> relevant, and the machine does not appear to have been overloaded at that
> time. Nothing appears in the event log at any rate.
>
> Has anyone else experienced the same sort of problem?
>
> Adrian
>
>
>
Author
17 Jan 2006 6:19 PM
Anthony DAngelo
I have experienced a different problem with WriteToSever inside try/catch:

I am attempting to BulkCopy records from a DataTable into a SQL 2005 Table
using the attached code: (I am using QA Data which is about 1000 rows)

Public Sub New()
SQLBCP = New SqlBulkCopy(Me.ConnectionString, 34)
ExceptionErrorTable = New SQLDataTable
SQLBCP.DestinationTableName = Me.DestinationTable
SQLBCP.BatchSize = 1000
End Sub

Public Function Execute(ByRef dtTable As DataTable) As Boolean
Dim bFlag As Boolean = True
Try
SQLBCP.WriteToServer(dtTable)
Catch sqlex As SqlException
bFlag = False
Finally
End Try
Return bFlag
End Function


If the Catch part is reached I have another routine that will write these
records to another table.  However, this routine never fires, becuase SQL
Server generates a No Yielding Message:

Process 66:0:0 (0xc14) Worker 0x4B27A0E8 appears to be non-yielding on
Scheduler 1. Thread creation time: 12781373946624. Approx Thread CPU Used:
kernel 15 ms, user 670281 ms. Process Utilization 22%. System Idle 64%.
Interval: 671610 ms.

When a subsequent query attempts to run log messages appear:

Message
Error: 701, Severity: 17, State: 123.

There is insufficient system memory to run this query.

I am destroying the BulkCopy Object with a SQLBCP.Close before I attempt to
run the subsequent actions.

....Just an aside the BulkCopy Class does not contain a memeber to assist in
writing errors to an output file like th /E switch in the bcp command line
utility.  Any future enhancements?



Show quote
"John Bell" wrote:

> Hi
>
> I have not run into your problem, but you may want to profile the system
> whilst you are running this and check for locking and blocking, also file
> expansion may be an issue if they occur at the same time.
>
> John
>
> "AdrianDams" wrote:
>
> > I have a system that fills a DataTable and periodically sends it to the SQL
> > Server using SQLBulkCopy.WriteToServer. On the whole, the solution works
> > great, but very occassionally I get a timeout exception. I have set the
> > bulkcopy timout to 30 seconds which, for my data load, is plenty. Typically
> > the bulk compy completes inside of a second or two.
> >
> > The SQL Server is on the local machine so  network conditions aren't
> > relevant, and the machine does not appear to have been overloaded at that
> > time. Nothing appears in the event log at any rate.
> >
> > Has anyone else experienced the same sort of problem?
> >
> > Adrian
> >
> >
> >
Author
17 Jan 2006 7:06 PM
John Bell
Hi

I am not sure why you would get this error assuming that your system has
enough resource! Have you tried increasing the Bulktimeout (just in case!).

For feature requests and bugs you can log them at
http://lab.msdn.microsoft.com/productfeedback/default.aspx

John

Show quote
"Anthony DAngelo" wrote:

> I have experienced a different problem with WriteToSever inside try/catch:
>
> I am attempting to BulkCopy records from a DataTable into a SQL 2005 Table
> using the attached code: (I am using QA Data which is about 1000 rows)
>
> Public Sub New()
> SQLBCP = New SqlBulkCopy(Me.ConnectionString, 34)
> ExceptionErrorTable = New SQLDataTable
> SQLBCP.DestinationTableName = Me.DestinationTable
> SQLBCP.BatchSize = 1000
> End Sub

> Public Function Execute(ByRef dtTable As DataTable) As Boolean
> Dim bFlag As Boolean = True
> Try
> SQLBCP.WriteToServer(dtTable)
> Catch sqlex As SqlException
> bFlag = False
> Finally
> End Try
> Return bFlag
> End Function

>
> If the Catch part is reached I have another routine that will write these
> records to another table.  However, this routine never fires, becuase SQL
> Server generates a No Yielding Message:
>
> Process 66:0:0 (0xc14) Worker 0x4B27A0E8 appears to be non-yielding on
> Scheduler 1. Thread creation time: 12781373946624. Approx Thread CPU Used:
> kernel 15 ms, user 670281 ms. Process Utilization 22%. System Idle 64%.
> Interval: 671610 ms.
>
> When a subsequent query attempts to run log messages appear:
>
> Message
> Error: 701, Severity: 17, State: 123.
>
> There is insufficient system memory to run this query.
>
> I am destroying the BulkCopy Object with a SQLBCP.Close before I attempt to
> run the subsequent actions.
>
> ...Just an aside the BulkCopy Class does not contain a memeber to assist in
> writing errors to an output file like th /E switch in the bcp command line
> utility.  Any future enhancements?
>
>
>
> "John Bell" wrote:
>
> > Hi
> >
> > I have not run into your problem, but you may want to profile the system
> > whilst you are running this and check for locking and blocking, also file
> > expansion may be an issue if they occur at the same time.
> >
> > John
> >
> > "AdrianDams" wrote:
> >
> > > I have a system that fills a DataTable and periodically sends it to the SQL
> > > Server using SQLBulkCopy.WriteToServer. On the whole, the solution works
> > > great, but very occassionally I get a timeout exception. I have set the
> > > bulkcopy timout to 30 seconds which, for my data load, is plenty. Typically
> > > the bulk compy completes inside of a second or two.
> > >
> > > The SQL Server is on the local machine so  network conditions aren't
> > > relevant, and the machine does not appear to have been overloaded at that
> > > time. Nothing appears in the event log at any rate.
> > >
> > > Has anyone else experienced the same sort of problem?
> > >
> > > Adrian
> > >
> > >
> > >
Author
17 Jan 2006 7:16 PM
Anthony DAngelo
Yes I did....I should have mentioned that.

I realize its a new class library, so the kinks still have to get worked out.

Thanks for the URL...I will open a ticket with MS as well.

Show quote
"John Bell" wrote:

> Hi
>
> I am not sure why you would get this error assuming that your system has
> enough resource! Have you tried increasing the Bulktimeout (just in case!).
>
> For feature requests and bugs you can log them at
> http://lab.msdn.microsoft.com/productfeedback/default.aspx
>
> John
>
> "Anthony DAngelo" wrote:
>
> > I have experienced a different problem with WriteToSever inside try/catch:
> >
> > I am attempting to BulkCopy records from a DataTable into a SQL 2005 Table
> > using the attached code: (I am using QA Data which is about 1000 rows)
> >
> > Public Sub New()
> > SQLBCP = New SqlBulkCopy(Me.ConnectionString, 34)
> > ExceptionErrorTable = New SQLDataTable
> > SQLBCP.DestinationTableName = Me.DestinationTable
> > SQLBCP.BatchSize = 1000
> > End Sub
> > 
> > Public Function Execute(ByRef dtTable As DataTable) As Boolean
> > Dim bFlag As Boolean = True
> > Try
> > SQLBCP.WriteToServer(dtTable)
> > Catch sqlex As SqlException
> > bFlag = False
> > Finally
> > End Try
> > Return bFlag
> > End Function
> > 
> >
> > If the Catch part is reached I have another routine that will write these
> > records to another table.  However, this routine never fires, becuase SQL
> > Server generates a No Yielding Message:
> >
> > Process 66:0:0 (0xc14) Worker 0x4B27A0E8 appears to be non-yielding on
> > Scheduler 1. Thread creation time: 12781373946624. Approx Thread CPU Used:
> > kernel 15 ms, user 670281 ms. Process Utilization 22%. System Idle 64%.
> > Interval: 671610 ms.
> >
> > When a subsequent query attempts to run log messages appear:
> >
> > Message
> > Error: 701, Severity: 17, State: 123.
> >
> > There is insufficient system memory to run this query.
> >
> > I am destroying the BulkCopy Object with a SQLBCP.Close before I attempt to
> > run the subsequent actions.
> >
> > ...Just an aside the BulkCopy Class does not contain a memeber to assist in
> > writing errors to an output file like th /E switch in the bcp command line
> > utility.  Any future enhancements?
> >
> >
> >
> > "John Bell" wrote:
> >
> > > Hi
> > >
> > > I have not run into your problem, but you may want to profile the system
> > > whilst you are running this and check for locking and blocking, also file
> > > expansion may be an issue if they occur at the same time.
> > >
> > > John
> > >
> > > "AdrianDams" wrote:
> > >
> > > > I have a system that fills a DataTable and periodically sends it to the SQL
> > > > Server using SQLBulkCopy.WriteToServer. On the whole, the solution works
> > > > great, but very occassionally I get a timeout exception. I have set the
> > > > bulkcopy timout to 30 seconds which, for my data load, is plenty. Typically
> > > > the bulk compy completes inside of a second or two.
> > > >
> > > > The SQL Server is on the local machine so  network conditions aren't
> > > > relevant, and the machine does not appear to have been overloaded at that
> > > > time. Nothing appears in the event log at any rate.
> > > >
> > > > Has anyone else experienced the same sort of problem?
> > > >
> > > > Adrian
> > > >
> > > >
> > > >

AddThis Social Bookmark Button