Issue Details (XML | Word | Printable)

Key: DNET-745
Type: Bug Bug
Status: Closed Closed
Resolution: Incomplete
Priority: Major Major
Assignee: Jiri Cincura
Reporter: Paul Reeves
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
.NET Data provider

Collection was modified; enumeration operation may not execute.

Created: 24/Mar/17 03:34 PM   Updated: 06/May/17 07:45 PM
Component/s: None
Affects Version/s: 5.8.0.0
Fix Version/s: None

Environment: .Net 4 and4.5


 Description  « Hide
We have a client that have found what appears to be a bug in v5.8.0.0

The code and the stack trace are attached below.

The same code works fine with all versions between 4.1 and 5.7

They've also tested with .Net framework 4 and 4.5

They are happy to run a debug build to help fix this, but have not been able to create a test case.



#if DEBUG
      var cmd = "select s.S_SHOPID, s.S_VALUE as FOO, s1.S_VALUE as BAR, s2.S_VALUE as SNAFU " +
                "from SYSTEMSETTING s " +
                "left join SYSTEMSETTING s1 on s.S_SHOPID = s1.S_SHOPID " +
                "left join SYSTEMSETTING s2 on s.S_SHOPID = s2.S_SHOPID " +
                "where s.S_SYSTEM_ID = 9202 " +
                "and s1.S_SYSTEM_ID = 9200 " +
                "and s2.S_SYSTEM_ID = 9201 " +
                "and s.S_VALUE = 'Y' " +
                "and s1.S_VALUE <> '' " +
                "and s2.S_VALUE <> ''";
      using (FbCommand fbCmd = new FbCommand(cmd)) {
        using (DataTable myDT = new DataTable()) {
          using (FbDataAdapter da = new FbDataAdapter()) {
            da.SelectCommand = fbCmd;
            fbCmd.Connection = DbConnection;

            try {
              LogFile.Log("Before Data Adapter.Fill() call. Managed Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString(), true);
              da.Fill(myDT);
              LogFile.Log("After Data Adapter.Fill() call. Managed Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString(), true);
              foreach (DataRow row in myDT.Rows) {
                LogFile.Log("Row Logged");
              }
            }
            catch (Exception e) {
              LogFile.Log("******--- ERROR ---******", true);
              LogFile.Log("Managed Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
              LogFile.Log("Error Message: " + e.Message);
              LogFile.Log("Error Message: " + e.StackTrace);
            }
          }
        }
      }
      LogFile.Log("After Select via SQL Test. Managed Thread ID: " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString(), true);
#endif


--------------------------------------------------------------------------------
Tuesday 21 March 2017 01:20:07.308 PM
--------------------------------------------------------------------------------
  :Before Select via SQL Test. Managed Thread ID: 4
  :FirebirdSql.Data.FirebirdClient version: 5.8.0.0
--------------------------------------------------------------------------------
Tuesday 21 March 2017 01:20:07.308 PM
--------------------------------------------------------------------------------
  :Before Data Adapter.Fill() call. Managed Thread ID: 4
--------------------------------------------------------------------------------
Tuesday 21 March 2017 01:20:07.313 PM
--------------------------------------------------------------------------------
  :******--- ERROR ---******
  :Managed Thread ID: 4
  :Error Message: Collection was modified; enumeration operation may not execute.
  :Error Message: at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Linq.Enumerable.<TakeIterator>d__24`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at FirebirdSql.Data.Client.Managed.XdrStream.Read(Byte[] buffer, Int32 offset, Int32 count) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\XdrStream.cs:line 249
   at FirebirdSql.Data.Client.Managed.XdrStream.ReadBytes(Int32 count) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\XdrStream.cs:line 336
   at FirebirdSql.Data.Client.Managed.XdrStream.ReadOpaque(Int32 length) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\XdrStream.cs:line 348
   at FirebirdSql.Data.Client.Managed.GdsConnection.ProcessOperation(Int32 operation, XdrStream xdr) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\GdsConnection.cs:line 362
   at FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadSingleResponse() in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:line 638
   at FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadResponse() in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:line 593
   at FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadGenericResponse() in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:line 605
   at FirebirdSql.Data.Client.Managed.Version11.GdsStatement.Prepare(String commandText) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version11\GdsStatement.cs:line 77
   at FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:line 1148
   at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:line 1171
   at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:line 523
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at PNDataService.DbConnectionManager.InitializeEvents(String errorstatus, Boolean resumedFromDownTime) in C:\Dev VS\PNDATASERVICEVS4.5\DbConnectionManager.cs:line 987
--------------------------------------------------------------------------------
Tuesday 21 March 2017 01:20:07.329 PM
--------------------------------------------------------------------------------
  :After Select via SQL Test. Managed Thread ID: 4




 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jiri Cincura added a comment - 05/Apr/17 12:54 PM
Are there events used (Firebird events - post_event, etc.)?

Also can they check with 5.8.1. Pieces inside this calls were bit reworked.

Paul Reeves added a comment - 07/Apr/17 01:53 PM
It looks as if the problem still exists. Here is their report...

"As soon as I uncommented the query that seems to cause all the mayhem I started getting errors on the first run.

2 out of 3 runs errored and the service stopped."


And some log output:


--------------------------------------------------------------------------------
Friday 07 April 2017 07:13:39.782 AM
--------------------------------------------------------------------------------
  :Before Select via SQL Test. Managed Thread ID: 4
  :FirebirdSql.Data.FirebirdClient version: 5.8.1.0
  :Service Assembly version: v4.0.30319
--------------------------------------------------------------------------------
Friday 07 April 2017 07:13:39.782 AM
--------------------------------------------------------------------------------
  :Before Data Adapter.Fill() call. Managed Thread ID: 4
--------------------------------------------------------------------------------
Friday 07 April 2017 07:13:39.809 AM
--------------------------------------------------------------------------------
  :******--- ERROR ---******
  :Managed Thread ID: 4
  :Error Message:
  :Error Message: at FirebirdSql.Data.FirebirdClient.FbCommand.Fetch()
   at FirebirdSql.Data.FirebirdClient.FbDataReader.Read()
   at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
   at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
   at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at PNDataService.DbConnectionManager.InitializeEvents(String errorstatus, Boolean resumedFromDownTime) in C:\......\DbConnectionManager.cs:line 1105
--------------------------------------------------------------------------------
Friday 07 April 2017 07:13:39.815 AM
--------------------------------------------------------------------------------
  :After Select via SQL Test. Managed Thread ID: 4