Ticket T520917
Visible to All Users

Empty rows in the grid control under certain circumstances

created 8 years ago (modified 8 years ago)

[DevExpress Support Team: CLONED FROM T520559: Questions about the "Entering the 'GetObjectsNonReenterant' state…" error]
Hi Dennis,

Thanks you for your response.
I've just put the application on production to see if it works fine and I see that the DataGrid does not crash on refreshing the DataGrid, which is good, but only when there are a few rows to show. when there are a lot of records it does not show the data, it shows only the empty rows. When I scroll up or down the DataGrid does not show the rows any more. After another refresh it shows again everything. It is look like that it happen randomly.
Do you have any suggestion?

Thanks

Update:

I've enabled CLR exception and disabled the "Just My Code" debugging. I get these exceptions:

1. On start:

System.InvalidOperationException occurred
  Message=Reenter detected!!!
  Source=DevExpress.Data.v11.2
  StackTrace:
       bij DevExpress.Data.Helpers.ServerModeCache.ReenterancyWatch…ctor(ServerModeCache watched)
  InnerException:

2. On after start:

System.Data.SqlClient.SqlException occurred
Message: Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Additional information: Time-out is verlopen. De time-outperiode is verstreken voordat de bewerking werd voltooid of de server reageert niet.

3. on auto refresh:

DevExpress.Data.Helpers.InconsistencyDetectedException occurred
  Message=Unexpected number of returned keys: 99. Expected: 98
  Source=DevExpress.Data.v11.2
  StackTrace:
       bij DevExpress.Data.Helpers.ServerModeCache.RaiseInconsistencyDetected(String message)
  InnerException:

4. On scroll up/down:

DevExpress.Data.Helpers.InconsistencyDetectedException occurred
  Message=Key '173683' fetched at index 7377 does not match previously fetched key '173682' for the same index
  Source=DevExpress.Data.v11.2
  StackTrace:
       bij DevExpress.Data.Helpers.ServerModeCache.RaiseInconsistencyDetected(String message)
  InnerException:

Show previous comments (3)
DM DM
David Maelfait 8 years ago

    Hello Sasha,

    Sorry for my delayed response, I was out of office for couple of days.

    The exception that I get right now is :

    DevExpress.Data.Helpers.InconsistencyDetectedException occurred
      Message=Key '248540' fetched at index 7800 does not match previously fetched key '248480' for the same index
      Source=DevExpress.Data.v11.2
      StackTrace:
           bij DevExpress.Data.Helpers.ServerModeCache.RaiseInconsistencyDetected(String message)
      InnerException:

    Then a Grid without data when I scroll up/dwon.

    You can find the the call stack in a text file.

    DM DM
    David Maelfait 8 years ago

      bij DevExpress.Data.Helpers.ServerModeCache.ReenterancyWatch…ctor(ServerModeCache watched)
         bij DevExpress.Data.Helpers.ServerModeCache.CreateTopGroupInfo()

      Sasha (DevExpress Support) 8 years ago

        Hello David,
        Thank you for the provided callstack. It was very helpful. According to the callstack, the reenter exception is thrown because the WMPaint method is called while the UI thread is locked. You can see it in the following callstack lines:

        C#
        DevExpress.XtraGrid.v11.2.dll!DevExpress.XtraGrid.GridControl.OnPaint(System.Windows.Forms.PaintEventArgs e = {ClipRectangle = {System.Drawing.Rectangle}}) System.Windows.Forms.dll!System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs e, short layer) System.Windows.Forms.dll!System.Windows.Forms.Control.WmPaint(ref System.Windows.Forms.Message m) System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) DevExpress.XtraEditors.v11.2.dll!DevExpress.XtraEditors.Container.EditorContainer.WndProc(ref System.Windows.Forms.Message m = {System.Windows.Forms.Message}) DevExpress.XtraGrid.v11.2.dll!DevExpress.XtraGrid.GridControl.WndProc(ref System.Windows.Forms.Message m = {System.Windows.Forms.Message}) System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 15, System.IntPtr wparam, System.IntPtr lparam) [Native to Managed Transition] [Managed to Native Transition] mscorlib.dll!System.Threading.WaitHandle.WaitOne(long timeout, bool exitContext) mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) System.Data.dll!System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() System.Data.dll!System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket() System.Data.dll!System.Data.SqlClient.TdsParserStateObject.ReadBuffer() System.Data.dll!System.Data.SqlClient.TdsParserStateObject.ReadByte()

        As you can see, the provider waits for a response from the server, and the WmPaint  method is called, causing the Grid refresh. This is known behavior. Common ways of resolving this problem are described in the Troubleshooting - How to resolve the "Entering the 'GetObjectsNonReenterant' state…" error KB Article. Please use one of the approaches suggested in paragraph 4, i.e., either use the STASafeDataStore wrapper or mark your app with the MTAThread attribute.

        As for the InconsistencyDetected exception, it indicates that the database was modified by another user. This exception is handled internally and when it occurs, XPServerCollectionSource is reloaded. According to the SQL query log provided in one of your previous comments, InvalidOperationException occurs when the second SQL query is executed:

        C#
        01.06.17 16:54:11.961 Executing sql 'select resultSet.F0 from(select N0."Rac_ID" as F0, row_number() over( order by N0."Rac_LastUpdate" desc,N0."Rac_ID" desc) as 'rowNumber' from "dbo"."VW_Reg_AccessControl2" N0 where ((N0."Rac_LevelId" = @p0) and (N0."Rac_LogDateTime" >= @p1) and (N0."Rac_LogDateTime" <= @p2)))resultSet where resultSet.rowNumber > 200 and resultSet.rowNumber <= 200 + 201' with parameters {204},{1/06/2017 15:54:09},{1/06/2017 16:54:09} 01.06.17 16:54:11.988 Result: rowcount = 201, total = 1608, N0.{Rac_ID,Int64} = 1608 Exception thrown: 'DevExpress.Data.Helpers.InconsistencyDetectedException' in DevExpress.Data.v11.2.dll 01.06.17 16:54:11.997 Executing sql 'select top 1 count(*) from "dbo"."VW_Reg_AccessControl2" N0 where ((N0."Rac_LevelId" = @p0) and (N0."Rac_LogDateTime" >= @p1) and (N0."Rac_LogDateTime" <= @p2))' with parameters {204},{1/06/2017 15:54:09},{1/06/2017 16:54:09} Exception thrown: 'System.InvalidOperationException' in DevExpress.Data.v11.2.dll 01.06.17 16:54:12.025 Result: rowcount = 1, total = 4, SubQuery{Count,,) = 4

        Likely, this is the same exception that is thrown when re-entrance occurs. Thus, the approach from the Troubleshooting - How to resolve the "Entering the 'GetObjectsNonReenterant' state…" error KB Article should help resolve the issue. If not, please provide us with the callstack of InvalidOperationException that occurs after the InconsistencyDetected exception. For this, reproduce the InconsistencyDetected exception and when the debugger breaks, ignore this exception and collect the callstack of the next exception.

        I look forward to your results.

        Answers

        created 8 years ago (modified 8 years ago)

        Thank you very much Sasha,

        The problem is solved.

        I put my code here, maybe other people can use it.

        public XPServerCollectionSource GetRegistrationsContent(string errorString, int levelId, string TableName, DateTime From, DateTime Until, XPServerCollectionSource current)
                {
                    XPServerCollectionSource result = current;
                    try
                    {
                        if (TableName == "Registrations" && (current == null || (current != null && !current.Session.IsObjectsLoading && !current.Session.IsObjectsSaving)))
                        {
                            CriteriaOperator criteria = CriteriaOperator.Parse("[Rac_LevelID] = ? AND [Rac_LogDateTime] >= ? AND [Rac_LogDateTime] <= ?", new object[] { levelId, From, Until });
                            if (current == null)
                            {
                                IDataStore dataStore = XpoDefault.GetConnectionProvider(ATRegistrationsConnectionString, AutoCreateOption.DatabaseAndSchema);
                                IDataStore provider = new STASafeDataStore(dataStore);
                                XpoDefault.DataLayer = new SimpleDataLayer(provider);
                                XPClassInfo classInfo = XpoDefault.Session.GetClassInfo(typeof(Registration));
                                result = new XPServerCollectionSource(XpoDefault.Session, classInfo, criteria);
                            }
                            else
                            {
                                current.FixedFilterCriteria = criteria;
                                current.Session.DropIdentityMap();
                                current.Reload();
                                result = current;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        OnErrorEv(0, errorString, e);
                    }
                    return result;
                }

          Comments (1)
          Sasha (DevExpress Support) 8 years ago

            Hello David,
            I am happy to hear that you have managed to resolve the issue.
            Please don't hesitate to contact us in case of further difficulties.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.