Skip to content

Ensure SqlBulkCopy timeout is extended for V17 migrations - #107

Merged
PerplexDaniel merged 1 commit into
PerplexDigital:masterfrom
osigas:increase-migration-sqlbulkcopy-timeout
Oct 13, 2026
Merged

PerplexDaniel merged 1 commit into
PerplexDigital:masterfrom
osigas:increase-migration-sqlbulkcopy-timeout

Conversation

@osigas

@osigas osigas commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

I've been upgrading one of our Umbraco applications from V13 to V17, and was getting timeouts from the MigrateFromNestedContentToBlockList migration when it was trying to persist the updated block property data to the database.

I was able to get this working locally by duplicating your migration with the addition of an extended BulkCopyTimeout, which defaults to 30 seconds if not set. There was already a 600 timeout on other database operations set in the code, but it was missing for SqlBulkCopy which uses a separate property.

Thought I'd PR this back in case anyone else runs into this in the future!

Before

Screenshot 2026-10-13 105648
Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
 ---> System.ComponentModel.Win32Exception (258): The wait operation timed out.
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParserStateObject.WriteSni(Boolean canAccumulate)
   at Microsoft.Data.SqlClient.TdsParserStateObject.WriteBytes(ReadOnlySpan`1 b, Int32 len, Int32 offsetBuffer, Boolean canAccumulate, TaskCompletionSource`1 completion, Byte[] array)
   at Microsoft.Data.SqlClient.TdsParser.WriteUnterminatedValue(Object value, MetaType type, Byte scale, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj, Int32 paramSize, Boolean isDataFeed)
   at Microsoft.Data.SqlClient.TdsParser.WriteBulkCopyValue(Object value, SqlMetaDataPriv metadata, TdsParserStateObject stateObj, Boolean isSqlType, Boolean isDataFeed, Boolean isNull)
   at Microsoft.Data.SqlClient.SqlBulkCopy.CopyColumnsAsync(Int32 col, TaskCompletionSource`1 source)
   at Microsoft.Data.SqlClient.SqlBulkCopy.CopyRowsAsync(Int32 rowsSoFar, Int32 totalRows, CancellationToken cts, TaskCompletionSource`1 source)
   at Microsoft.Data.SqlClient.SqlBulkCopy.CopyBatchesAsyncContinued(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource`1 source)
   at Microsoft.Data.SqlClient.SqlBulkCopy.CopyBatchesAsync(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource`1 source)
   at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet internalResults, CancellationToken cts, TaskCompletionSource`1 source)
   at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestAsync(CancellationToken cts, TaskCompletionSource`1 source)
   at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerInternalAsync(CancellationToken ctoken)
   at Microsoft.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServerAsync(Int32 columnCount, CancellationToken ctoken)
   at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(DataTable table, DataRowState rowState)
   at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(DataTable table)
   at NPoco.SqlServer.SqlBulkCopyHelper.BulkInsert[T](IDatabase db, IEnumerable`1 list, SqlBulkCopyOptions sqlBulkCopyOptions, InsertBulkOptions insertBulkOptions)
   at Umbraco.Cms.Persistence.SqlServer.Services.UmbracoSqlServerDatabaseType.InsertBulk[T](IDatabase db, IEnumerable`1 pocos, InsertBulkOptions options)
   at NPoco.Database.InsertBulk[T](IEnumerable`1 pocos, InsertBulkOptions options)
   at Perplex.ContentBlocks.Migrations.M001_MigrateFromNestedContentToBlockList.MigrateFromNestedContentToBlockList.<MigrateContentBlocksPropertyData>g__BulkUpdate|9_13(<>c__DisplayClass9_0&, <>c__DisplayClass9_1&) in D:\projecten\Perplex.ContentBlocks\src\Perplex.ContentBlocks.Core\Migrations\M001_MigrateFromNestedContentToBlockList\MigrateFromNestedContentToBlockList.cs:line 375

After

Screenshot 2026-10-13 105457

@PerplexDaniel
PerplexDaniel merged commit 5158d26 into PerplexDigital:master Oct 13, 2026
@PerplexDaniel

Copy link
Copy Markdown
Member

Thanks @osigas, good find! I will include this in the next patch release (v4.0.6).

@osigas
osigas deleted the increase-migration-sqlbulkcopy-timeout branch October 13, 2026 11:00
@PerplexDaniel

Copy link
Copy Markdown
Member

@osigas v4.0.6 is released on NuGet.org!

@osigas

osigas commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@osigas v4.0.6 is released on NuGet.org!

Thank you for the speedy release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants