gluwa / Nethereum.Npgsql

MIT License
3 stars 2 forks source link

FlushAsync problem if there are too many decimals the driver says we need to use FlushAsync #5

Open dlebee opened 4 months ago

dlebee commented 4 months ago

Might be related to https://github.com/npgsql/npgsql/issues/5362

How to reproduce change demo to use 101 iterations instead of 72

we don't need that many decimals right now, but i'll try to see the caps and if the bytes buffer is too larger I could Write -> FlushAsync then Write -> FlushAsync that may solve the problem.


 ---> System.NotSupportedException: Cannot call Flush on a non-blocking PgWriter, call FlushAsync instead.
   at Npgsql.Internal.PgWriter.Flush(Boolean allowWhenNonBlocking, TimeSpan timeout)
   at Npgsql.Internal.PgWriter.WriteBytes(Boolean allowMixedIO, ReadOnlySpan`1 buffer)
   at Npgsql.Internal.PgWriter.WriteBytes(ReadOnlySpan`1 buffer)
   at Nethereum.Npgsql.BigDecimalConverter.WriteCore(PgWriter writer, BigDecimal value) in /Users/gluwadl/Dev/Experimentations/Nethereum.Npgsql/Nethereum.Npgsql/BigDecimalConverter.cs:line 83
   at Npgsql.Internal.PgBufferedConverter`1.Write(PgWriter writer, T value)
   at Npgsql.Internal.PgBufferedConverter`1.WriteAsObject(Boolean async, PgWriter writer, Object value, CancellationToken cancellationToken)
   at Npgsql.Internal.PgConverter.WriteAsObjectAsync(PgWriter writer, Object value, CancellationToken cancellationToken)
   at Npgsql.NpgsqlParameter.WriteValue(Boolean async, PgWriter writer, CancellationToken cancellationToken)
   at Npgsql.NpgsqlParameter.Write(Boolean async, PgWriter writer, CancellationToken cancellationToken)
   at Npgsql.Internal.NpgsqlConnector.WriteBind(List`1 parameters, String portal, Byte[] asciiName, Boolean allResultTypesAreUnknown, Boolean[] unknownResultTypeList, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.<Write>g__WriteExecute|100_0(NpgsqlConnector connector, Boolean async, Boolean flush, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Program.<Main>$(String[] args) in /Users/gluwadl/Dev/Experimentations/Nethereum.Npgsql/Demo/Program.cs:line 59
   at Program.<Main>(String[] args)```
dlebee commented 4 months ago

to be more specific it breaks exactly at i == 92, which means

92 whole numbers and 92 decimal numbers.