New Posts New Posts RSS Feed: Weird Intermittent Error
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Weird Intermittent Error

 Post Reply Post Reply
Author
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Topic: Weird Intermittent Error
    Posted: 27-Dec-2012 at 3:14am
Hi guys,

We're using EntityInstantFeedbackSource of Devexpress for our Search Form purposes with Devforce nTier Architecture as the datasource.

Now, majority of our Search Form that queries different kind of tables are working well but some are experiencing issue like "Collection has been modified" during loading or "Index is out of range".

The problem is that, the issue is intermittent and we can hardly replicate the issue and we don't know when the bug will appear.

I managed to get some details, can you determine what causes this stack trace?

   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at IdeaBlade.EntityModel.PendingEntityMap.FindByFromEntity(EntityAspect fromAspect)
   at IdeaBlade.EntityModel.PendingEntityMap.Update(EntityAspect pendingAspect, EntityAspect realAspect)
   at IdeaBlade.EntityModel.ScalarEntityReference`1.InformPendingEntityOfRealEntity(EntityAspect realEntity)
   at IdeaBlade.EntityModel.ScalarEntityReference`1.QueryCallback(EntityQueryOperation op)
   at IdeaBlade.EntityModel.BaseOperation`2.OnCompleted()
   at IdeaBlade.EntityModel.BaseOperation`2.IdeaBlade.EntityModel.IHasAsyncEventArgs.OnCompleted()
   at IdeaBlade.EntityModel.AsyncProcessor`1.<>c__DisplayClass2.<.ctor>b__0(TArgs args)

Here's the link of our model project   uploads/1228/iRely.Model2.rar
, try to check the table tblSMSecurityUser, because that's the entity that we're using to query for that specific Search Form issue.



Thanks,
Von
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 27-Dec-2012 at 2:27pm
This could indicate a multi-threading problem.
 
Can you show us the code for your query (or queries) which you think might be involved?
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 27-Dec-2012 at 3:06pm
Ths is our code:

We created a generic Search Form.

                    var constructorInfo = typeof(E).GetConstructor(new Type[] { 
                                                                        typeof(bool), 
                                                                        typeof(string) , 
                                                                        typeof(EntityServiceOption), 
                                                                        typeof(string) 
                    });

                    var entityManager = constructorInfo.Invoke(new object[] {   
                                                                        true, 
                                                                        ConnectionKey,  
                                                                        EntityServiceOption.UseDefaultService,
                                                                        null}) as E;

                    ContextManagerBase<T, E> contextManager = new ContextManagerBase<T, E>(entityManager);


                    var finalQuery = contextManager.BaseQuery.Where(Filter == null ? p => true : Filter);
                    e.QueryableSource = finalQuery as IQueryable;

Where baseQuery is GetQuery<T>, so basically a basic query.

Thanks,
Von

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 27-Dec-2012 at 5:14pm
If you construct a new EntityManager for a search and do not use the EM on any other threads, then it's difficult to divine the problem here.  As you know, the EM is not thread safe, and its internal PendingEntityMap, which is at issue here, is also not thread safe.  Under "normal" conditions, at least all test conditions I can come up with which use the EM on a single thread, the error is not reproducible.
 
The PendingEntityMap is used to resolve "pending" entities, which are created for any navigation properties which must be resolved asynchronously.  When you query tblSMSecurityUser, are you accessing any of its navigation properties after the results are returned?   If you're loading results into a DataGrid, could the grid be accessing them?  Could any event handlers for any UI controls be accessing the navigation properties?  You should look for a situation where this EM, or any entity within it, is being accessed from another thread.  You can use the server's debug log to help determine which navigation properties are accessed, since these relation queries are written to the log.  The EM Querying event is another good candidate to add debugging diagnostics.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down