DeleteNode is too slow and causes all nodes to lock

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
jonathang
Hero Member
Hero Member
Posts: 32
Joined: 02 Nov 2015, 19:07

DeleteNode is too slow and causes all nodes to lock

Post by jonathang »

Dear Support Team,

In my OPC UA Server, I have dynamically created folders that contains dynamically created objects with multiple nodes. The folders are set as ParentAsOwner (http://forum.unified-automation.com/topic1746.html) so that deleting a folder, deletes all objects/nodes within it.

This works very well for folders with few objects/nodes (2200 nodes total) and takes a few seconds; however, for larger node sets (88000 nodes), just deleting the parent folder takes 12 minutes. During this time, no other node on the system is updated or can be accessed. I believe this has something to do with locks that prevent multiple threads from accessing the same node.

I delete the parent folder with this, where nodeToDelete is the NodeId of the parent folder.

Code: Select all

private void DeleteOpcNode(NodeId nodeToDelete)
{
    lock (InMemoryNodeLock)
    {
        DeleteNode(Server.DefaultRequestContext, nodeToDelete, true);
    }
}
I tried the same code without the lock with identical results. I am also running the code in a background thread. This is not my actual code but a close approximation.

Code: Select all

Task.Factory.StartNew(() =>
{
    DeleteOpcNode(nodeToDelete);
});
I use Internal node handle type with .NET OPC UA SDK 2.5.1 and .NET Framework 4.6.1.

Is there a way to delete so many nodes faster?

Is there a way to not lock other nodes while some nodes are being deleted?

Are using locks as above necessary?

Sincerely,

Jonathan

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: DeleteNode is too slow and causes all nodes to lock

Post by Support Team »

Hi,

When calling DeleteNode the NodeManager collects all other nodes that are children of the node to delete. These are the children of the nodes that are created based on the TypeDefinition and the nodes that are created with ParentAsOwner set to true. So a user of the SDK can delete a whole "subtree" of the addressspace with one line of code.

Since the collecting of the children has to be done recursively (including some additional checks in each recursive method call) the performance can get bad if the number of collected nodes to delete gets large.

In your case (many nodes to delete) you should not set ParentAsOwner to true. Instead of that you should delete the nodes separately.
Best regards
Unified Automation Support Team

sudha
Full Member
Full Member
Posts: 5
Joined: 01 Mar 2018, 14:15

Re: DeleteNode is too slow and causes all nodes to lock

Post by sudha »

Hi,

How can i set a node as parentAsOwner using AddNodes service as i am creating a node using add nodes service(.net sdk) i want to set this parameter to my node.

Is there anyway to set it ?

Post Reply