I have a method that is inserting into a table an Id, a set of UDT, and a date.
public async Task InsertAsync(SomeObject obj) { var statement = BindValues( InsertStatement.Value, new dynamic[] { obj.Id, obj.Messages, obj.Updated } ); await CassandraDB.Instance.Session.ExecuteAsync(statement); }
At some point this method throws an exception.
Collection was modified; enumeration operation may not execute. at System.Collections.Generic.List`1.Enumerator.MoveNextRare() at Cassandra.Serialization.CollectionSerializer.Serialize(UInt16 protocolVersion, IEnumerable value) at Cassandra.Serialization.GenericSerializer.Serialize(ProtocolVersion version, Object value) at Cassandra.QueryProtocolOptions.Write(FrameWriter wb, Boolean isPrepared) at Cassandra.Requests.BaseRequest.WriteFrame(Int16 streamId, MemoryStream stream, ISerializer connectionSerializer) at Cassandra.OperationState.WriteFrame(Int16 streamId, MemoryStream memoryStream, ISerializer serializer, Int64 timestamp) at Cassandra.Connections.Connection.RunWriteQueueAction() --- End of stack trace from previous location where exception was thrown ---
Can anyone help me with what could possibly cause that? As I'm understanding the obj.Messages is changed somewhere down the road? Or like it's possible that it's changed in a function that calls InsertAsync(...), but right after calling InsertAsync(...) it changes the obj.Messages value?