Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection was modified; enumeration operation may not execute. [DNET745] #687

Closed
firebird-issue-importer opened this issue Mar 24, 2017 · 4 comments

Comments

@firebird-issue-importer

Submitted by: @reevespaul

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 5, 2017

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 5, 2017

Commented by: @cincuranet

Are there events used (Firebird events - post_event, etc.)?

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 7, 2017

Commented by: @reevespaul

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented May 6, 2017

Modified by: @cincuranet

status: In Progress [ 3 ] => Closed [ 6 ]

resolution: Incomplete [ 4 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants