linq2db: Index was out of range
I am running dbContext.BulkCopyAsync twice. It works the first time. The second time it completes the insert, but then throws an index out of range error. If I continue, then I get a Npgsql.NpgsqlException: 'Exception while reading from stream'
TimeoutException: Timeout during reading attempt
. I am using EF Core 5.0. I have a converter in place to handle my ulongs. There are ulongs in the orgs type, so that doesn’t seem to be it.
Exception message:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')'
Stack trace:
This exception was originally thrown at this call stack:
System.ThrowHelper.ThrowArgumentOutOfRange_IndexException() in ThrowHelper.cs
Npgsql.NpgsqlDataReader.ProcessMessage(Npgsql.IBackendMessage) in NpgsqlDataReader.cs
Npgsql.NpgsqlDataReader.NextResult(bool, bool, System.Threading.CancellationToken) in NpgsqlDataReader.cs
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) in TaskAwaiter.cs
Npgsql.NpgsqlCommand.ExecuteReader(System.Data.CommandBehavior, bool, System.Threading.CancellationToken) in NpgsqlCommand.cs
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) in TaskAwaiter.cs
...
[Call Stack Truncated]
Steps to reproduce
var options = new LinqToDB.Data.BulkCopyOptions
{
KeepIdentity = true
};
await dbContext.BulkCopyAsync(options, orgs);
await dbContext.BulkCopyAsync(options, leagues); // index out of range
public class League
{
public int Id { get; set; }
public LeagueState State { get; set; }
public ulong ChannelId { get; set; }
public string Initials { get; set; } = string.Empty;
public string? Image { get; set; }
public int OrgId { get; set; }
public Org Org { get; set; }
public int Season { get; set; }
public int? WarMatchId { get; set; }
public List<Participant> Participants { get; set; }
}
Environment details
linq2db version: 3.1.6 Database Server: Postgres Database Provider: Npgsql Operating system: Windows 10 .NET Framework: .net 5.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 36 (21 by maintainers)
Looks like something wrong with async in npgsql 5, as we are getting errors from async code even from other providers when run tests alongside with npgsql. I will investigate and report it to npgsql repo
That worked though.