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

[Client] Read large dictionaries #2782

Merged

Conversation

ThomasNehring
Copy link
Contributor

Proposed changes

A new method is implemented which reads byte strings in chunks and therefore allows to read byte strings which exceed the encoding limits of the server. This is used in the method which reads v103 data dictionaries.

Related Issues

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

I have extended the ISession interface by a method ReadByteStringInChunks. Extending the interface may be considered a breaking change.

The new method takes a node id as input (which must point to a valid byte string typed variable) and is supposed to return the byte string value from that node id, even if it is too large for the server to encode it. It is implemented in Session and TraceableSession and used in the DataDictionary class, when the Read call to read the byte string which contains the dictionary fails with a BadEncodingLimitsExceeded` Service Result Exception.

(The method is currently intended to only fix the scenario in the bug mentioned. But as it is also exposed in the interface it could be used to read any byte string. The logic in that method is, in principal, also valid when reading other byte strings than data dictionaries or strings which are too large, or arrays which are too large).

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 75.32468% with 19 lines in your changes missing coverage. Please review.

Project coverage is 54.83%. Comparing base (c16d1f2) to head (40aa099).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
Libraries/Opc.Ua.Client/DataDictionary.cs 61.90% 6 Missing and 2 partials ⚠️
Libraries/Opc.Ua.Client/Session/Session.cs 83.33% 4 Missing and 4 partials ⚠️
...ibraries/Opc.Ua.Client/Session/TraceableSession.cs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2782      +/-   ##
==========================================
+ Coverage   54.73%   54.83%   +0.10%     
==========================================
  Files         349      349              
  Lines       65975    66040      +65     
  Branches    13534    13546      +12     
==========================================
+ Hits        36114    36216     +102     
+ Misses      25939    25900      -39     
- Partials     3922     3924       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
catch
{
ExceptionDispatchInfo.Capture(ex).Throw();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this dispatchInfo for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ReadByteStringInChunks method is called from within a catch block. If it also fails with an exception the original exception is rethrown together with it's call stack information (which, to my knowledge, would be lost if I just throw it).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho this is not needed when immediately rethrowing like in this case

Copy link
Contributor Author

@ThomasNehring ThomasNehring Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not rethrowing immediately. I'm rethrowing after executing ReadByteStringInChunks, which in turn can also throw an exception.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the second throw; then ever executed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now confused. Does this become an aggregatedException?

@ThomasNehring ThomasNehring changed the title Local/readlargedictionary02 [Client} Read Largedictionaries Oct 7, 2024
@ThomasNehring ThomasNehring changed the title [Client} Read Largedictionaries [Client} Read large dictionaries Oct 7, 2024
@ThomasNehring ThomasNehring changed the title [Client} Read large dictionaries [Client] Read large dictionaries Oct 7, 2024

int count = (int)ServerMaxByteStringLength; ;

int my_MaxByteStringLength = m_configuration.TransportQuotas.MaxByteStringLength;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: quite an uncommen prefix

Copy link
Contributor

@mregen mregen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, since the new code is only used when the dictionary is too big, low risk.

@mregen mregen merged commit a29d871 into OPCFoundation:master Oct 9, 2024
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataDictionaries which are larger than the servers Transport Quota Encoding limits cannot be read
3 participants