Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Maximum call stack exceeded with addRelatedUpdate and Tree root node

    Hello,

    I have a tree grid that displays nodes with counts values for statuses and I have a ListGrid where this status value can be edited. I want the count values in the tree for the respective nodes to be updated when an edit is made. In the ListGrid's custom data source on executeUpdate, I call addRelatedUpdate for the Tree data source and pass in just the tree nodes whose count has been updated from the leaf node to the root node, but whenever I pass the root node in the related update, I get a 'Maximum call stack exceeded' error (copied below). If I remove that node from the list for the related update, the tree loads fine with the counts for all other tree items (except the root node, of course, since I didn't pass it in). Why is this error get thrown for the root node?

    We are using SmartClient v8.3p_2013-07-18/Pro Deployment (built 2013-07-18).

    Code:
    12:01:28.819:XRP5:WARN:ResultTree:isc_ResultTree_0 (created by: hierarchyTree):Adding node to tree with id property set to:10302. A node with this ID is already present in this Tree - that node will be replaced. Note that this warning may be disabled by setting the reportCollisions attribute to false.
    12:01:28.820:XRP5:WARN:ResultTree:isc_ResultTree_0 (created by: hierarchyTree):Adding node to tree with id property set to:10401. A node with this ID is already present in this Tree - that node will be replaced. Note that this warning may be disabled by setting the reportCollisions attribute to false.
    12:01:28.913:XRP5:WARN:Log:RangeError: Maximum call stack size exceeded
    Stack from error.stack:
        Array.join() @ native
        .debug._getStackTraceFromArgs() @ ISC_Core.js:692:42[d]
        .debug_getStackTrace() @ ISC_Core.js:682:229[d]
        [c]Timer.setTimeout() @ ISC_Core.js:954:21[d]
        markForAddToLog() @ ISC_DeveloperConsole.js:63:179[d]
        addToLog() @ ISC_DeveloperConsole.js:62:145[d]
        LogViewer.addToLog() @ ISC_Core.js:768:225
        eval() @ ISC_Core.js:61:76), <anonymous>:3:209
        isc_c_Log_addLogMessage() @ ISC_Core.js:735:164
        isc_c_Log_log() @ ISC_Core.js:729:6
        isc.$63b() @ ISC_Core.js:783:25
    Thanks.

    #2
    That's a very strange stack trace. It suggests that there's a crash going on inside the Developer Console, not your application as such.

    What browser and version is this from?

    Have you enabled any special log categories (maybe "traceTimers"?).

    Comment


      #3
      I am using the latest version of Chrome (Version 29.0.1547.65) but I also tried on Firefox (Version 21.0).
      I am on Smart Client v8.3p_2013-07-18/Pro Deployment.

      In Firefox, I get the error "too much recursion." When I look at the Smart Client developer console, I see the following. Both in Chrome and FF, the developer console seems to print out the message "Adding node to tree with id property set to:...." multiple times for each node implying an infinite loop somewhere. In FF, instead of the snippet I posed in the previous post (which was from Chrome), it displays a different exception:

      Code:
      ...
      13:12:45.206:XRP2:WARN:ResultTree:isc_ResultTree_0 (created by: hierarchyTree):Adding node to tree with id property set to:10401. A node with this ID is already present in this Tree - that node will be replaced. Note that this warning may be disabled by setting the reportCollisions attribute to false.
      13:12:45.206:XRP2:WARN:ResultTree:isc_ResultTree_0 (created by: hierarchyTree):Adding node to tree with id property set to:10302. A node with this ID is already present in this Tree - that node will be replaced. Note that this warning may be disabled by setting the reportCollisions attribute to false.
      13:12:45.206:XRP2:WARN:ResultTree:isc_ResultTree_0 (created by: hierarchyTree):Adding node to tree with id property set to:10401. A node with this ID is already present in this Tree - that node will be replaced. Note that this warning may be disabled by setting the reportCollisions attribute to false.
      13:12:45.206:XRP2:WARN:ResultTree:isc_ResultTree_0 (created by: hierarchyTree):Adding node to tree with id property set to:10302. A node with this ID is already present in this Tree - that node will be replaced. Note that this warning may be disabled by setting the reportCollisions attribute to false.
      13:12:45.489:XRP2:WARN:Log:InternalError: too much recursion
      Stack from error.stack:
          unnamed(isc_Arra_indexO)
          unnamed(isc_Arra_remov)
          unnamed(isc_Tree_remov)
          unnamed(isc_Tree__ad)
          unnamed(isc_Tree__addLis)
          unnamed(isc_Tree__ad)
          unnamed(isc_Tree__addLis)
          ....
          unnamed(isc_Tree__ad)
          unnamed(isc_Tree__addLis)
          unnamed(isc_Tree_addLis)
          unnamed(isc_Tree_moveLis)
          unnamed(isc_Tree_mov)
          unnamed(isc_ResultTree__updateNodeInCach)
          unnamed(isc_ResultTree_updateCacheDat)
          unnamed(isc_ResultTree_updateCach)
          unnamed(isc_ResultTree_handleUpdat)
          unnamed(isc_ResultTree_dataSourceDataChange)
          unnamed(anonymou)
          unnamed(isc_DataSource_updateCache)
          unnamed(isc_DataSource__completeResponseProcessin)
          unnamed(isc_DataSource__handleSCServerRepl)
          unnamed(isc_c_Class_fireCallbac)
          unnamed(isc_Class_fireCallbac)
          unnamed(isc_c_RPCManager_fireReplyCallbac)
          unnamed(isc_c_RPCManager_fireReplyCallback)
          unnamed(isc_c_RPCManager_performOperationRepl)
          unnamed(isc_c_RPCManager__performTransactionRepl)
          unnamed(isc_c_RPCManager_performTransactionRepl)
          unnamed(anonymou)
          unnamed(isc_c_Class_fireCallbac)
          unnamed(isc_c_Comm_performXmlTransactionRepl)
          unnamed(anonymou)
          unnamed(isc_c_Class_fireCallbac)
          unnamed(isc_c_Comm__fireXMLCallbac)
          unnamed(isc_c_Comm_sendXmlHttpRequest/_1)
          unnamed() @
      In the developer console, I just have the log level set to Debug. I don't believe I have any trace timer logging categories.

      Comment


        #4
        We found a way to reproduce a crash like this, but it requires setting the idField of a node to the same as the parentIdField, in other words making a node it's own parent. Does that explain your issue?

        Comment


          #5
          Yea, with the way our data is, our root node has itself as a parent. Below is what our DS definition looks like.

          Would you be able to have a fix for this sometime this week? We are planning to upgrade to the latest SC 8.3 build for some other fixes this week so we can upgrade just once when this issue is fixed too.

          Code:
          <DataSource ID="OurTreeDS" schemaBean="model.OurTreeDataSource"
          	serverConstructor="spring:ourTreeDataSource">
          	<fields>
          		<field primaryKey="true" name="id" title="ID" type="integer" required="true" />
          		<field name="ancestorNodeId" type="integer" required="true" foreignKey="id"
          			rootValue="0" detail="true" />
          		<field name="description" title="Title" type="text" />
          		<field name="resolvedCount" title="Resolved" type="integer" />
          		<field name="unresolvedCount" title="Unresolved" type="integer" />
          		<field name="alertCount" title="Total" type="integer" />
          		<field name="isFolder" type="boolean" />
          		<field name="isOpen" type="boolean" />
          	</fields>
          </DataSource>
          Last edited by mgreenberg; 16 Sep 2013, 08:44. Reason: Added a question regarding the fix.

          Comment


            #6
            It's fine if the root node has a parent in your data model. What will cause an error like you saw is if a node has *itself* as a parent (which is obviously invalid).

            By the way, the latest builds will warn about this error and avoid infinite recursion.

            Comment


              #7
              Thanks for your response. Yes, that is how we have it. Our root node has itself as a parent. We have had it this way for a while and not had any issues until now with the tree loading, but only had started having issues when using addRelatedUpdate. What is the root node supposed to have instead as its ancestor/parent id? Can it be null?

              How does the latest build avoid infinite recursion? I believe it will take a lot of work to try to change our tree implementation for the root node, so I wanted to understand if infinite recursion will be avoided and the addRelatedUpdate for the root node will work in this case.

              Comment


                #8
                I tried modifying our data source to return the root node with ancestorNodeId to be null instead of the same ID to get rid of that recursive error. The tree loads fine initially (as before) when I load the page, but now when I try to perform the addRelatedUpdate by returning this same root node with parentId (ancestorNodeId) as null, the tree doesn't load. There aren't any JS errors and no errors in the SC console.
                What is going on?

                EDIT: I figured out how to fix this. In my *.ds.xml file, I specified null as rootValue instead of 0 and it seems to work now.
                Last edited by mgreenberg; 16 Sep 2013, 12:29. Reason: Figured out a fix.

                Comment


                  #9
                  Right, rootValue in the .ds.xml is the right setting for this.

                  Did that correct your issue completely or is there still something wrong? If there is still something wrong, we'll probably need to see code we can run to reproduce the issue.

                  Comment


                    #10
                    Thanks for confirming Isomorphic. This corrected my issue completely. Thanks for your help again.

                    Comment


                      #11
                      addRelatedUpdate with parent id different from rootValue

                      I know this post was from a while ago and I said we figured out a fix but it looks like it is fixed only for a certain case but not all.

                      We show a different hierarchy in the tree starting from a different root node based on a user's login. When a user is a top level user, the root node in our DB has its parentID as null, but when a user is not a top level user, the root id is its parent's ID. The definition in our .ds.xml has rootValue set as null. See .ds.xml below.

                      Take for example the simple hierarchy below. The top-most level user is 500 and a bottom level user is say, 200. When logged in as 500 and I perform an addRelatedUpdate with nodes from 100 to 500 (100, 200, 300, 400 and 500), the tree is updated fine. I am assuming this is the case because rootValue is set to null in the *.ds.xml which matches the ancestorNodeId.

                      However, if I am logged in as a bottom level user such as 200 and perform an addRelatedUpdate on the nodes 100 and 200, the resulting tree is just blank with no results. I think this is because ancestorNodeId for node 200 is 300 and not null (not matching rootValue in *.ds.xml). If the tree loaded fine originally and the addRelatedUpdate returns a subset of the tree nodes from the loaded tree with the same ancestorNodeId, I would think it should be able to find those tree nodes in the current tree and update those nodes fine with no problem instead of depending on rootValue. Is there some other setting in the ds.xml file that I am missing? Any help would really be appreciated.

                      id | ancestorNodeId
                      500 | null
                      400 | 500
                      300 | 400
                      200 | 300
                      100 | 200

                      Code:
                      <DataSource ID="OurTreeDS" schemaBean="model.OurTreeDataSource"
                      	serverConstructor="spring:ourTreeDataSource">
                      	<fields>
                      		<field primaryKey="true" name="id" title="ID" type="integer" required="true" />
                      		<field name="ancestorNodeId" type="integer" required="true" foreignKey="id"
                      			rootValue="null" detail="true" />
                      		<field name="description" title="Title" type="text" />
                      		<field name="resolvedCount" title="Resolved" type="integer" />
                      		<field name="unresolvedCount" title="Unresolved" type="integer" />
                      		<field name="alertCount" title="Total" type="integer" />
                      		<field name="isFolder" type="boolean" />
                      		<field name="isOpen" type="boolean" />
                      	</fields>
                      </DataSource>
                      Thanks.

                      Comment


                        #12
                        The only issue we've been able to uncover from any of your descriptions is that setting a node with itself as a parent, which is obviously invalid, used to cause an infinite loop and now causes a warning.

                        There's no dependency on rootValue being null, or being any particular value, with addRelatedUpdates() and ResultTree cache updates.

                        However, if you believe this is somehow the issue, you could "work around" this by setting the rootValue to be tree-specific via TreeGrid.dataProperties, or by massaging the data so that user-specific data can also use a root value of null.

                        But we suspect that in doing so, you are probably working around some bug in your own code rather than in SmartGWT. If you think the fault really is with SmartGWT, we'll need a minimal, ready-to-run test case demonstrating the problem in order to investigate.

                        Comment

                        Working...
                        X