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

Opc.Ua.Server SamplingGroup is spawning too many threads. #2983

Closed
1 of 5 tasks
dardigem opened this issue Feb 5, 2025 · 4 comments · Fixed by #2984
Closed
1 of 5 tasks

Opc.Ua.Server SamplingGroup is spawning too many threads. #2983

dardigem opened this issue Feb 5, 2025 · 4 comments · Fixed by #2984

Comments

@dardigem
Copy link

dardigem commented Feb 5, 2025

Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

The $SDK\Server\NodeManager\SamplingGroup class from V1.04 or above Opc.Ua.Server library spawns a sperate new thread for each monitoredItem being added to the same sampling group.

Expected Behavior

The SamplingGroup is expected to sample all MonitoredItems with same sampling interval on the same thread. It should not spawn separate thread in each call for ApplyChanges.

The $SDK\Server\NodeManager\SamplingGroup class from V1.02 had correct behavior.

Root cause of the issue:
The SamplingGroup::ApplyChanges starts the group even if the group is already running.

Description of fix:
File: $SDK\Server\NodeManager\SamplingGroup
Ad a new member variable to hold the task that is created in Startup function. Set the default value to null.

Function: Startup

  • Store the task returned by Task.Factory.StartNew in the member variable.

Function: ApplyChanges

  • Call Startup if (m_items.Count > 0 && null == m_task)

Steps To Reproduce

No response

Environment

- OS:
- Environment:
- Runtime:
- Nuget Version:
- Component:
- Server:
- Client:

Anything else?

No response

@romanett
Copy link
Contributor

romanett commented Feb 6, 2025

Good Catch I proposed a fix in #2984

@dardigem
Copy link
Author

dardigem commented Feb 6, 2025

Thank you for investigating the issue and for having the fix. I appreciate it.

I viewed the code changes proposed in #2984
The code changes look fine.
I think we also need to set the m_samplingTask to null in the function 'public void Shutdown()' in $SDK\Server\NodeManager\SamplingGroup

@romanett
Copy link
Contributor

romanett commented Feb 6, 2025

@dardigem thanks for the hint, not really important as the sampling group is disposed anyway, but good practice

@dardigem
Copy link
Author

dardigem commented Feb 6, 2025

Thank you. I agree!
👍

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