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

[Bug]: Prevent Critical Path code from throwing exceptions #1779

Closed
yurishkuro opened this issue Sep 12, 2023 · 6 comments · Fixed by #1780 or #1785
Closed

[Bug]: Prevent Critical Path code from throwing exceptions #1779

yurishkuro opened this issue Sep 12, 2023 · 6 comments · Fixed by #1780 or #1785

Comments

@yurishkuro
Copy link
Member

What happened?

Critical Path code occasionally throws Range exception here:

throw RangeError(`Error while computing Critical Path Algorithm.`);

Steps to reproduce

Unknown, the failures have been happening sporadically in CI

Expected behavior

Code should handle all input trace data, fall back gracefully to not returning CP if impossible to calculate.

Relevant log output

No response

Screenshot

No response

Additional context

We need to rethink the switch statement. The relative positioning of parent/child spans has a fixed number of permutations, they should be covered by the appropriate if-conditions, ideally in a hierarchical manner, e.g.

if child starts after parent
  if child ends before parent
    etc.

The function should also be simplified to do early returns. For example, instead of introducing a nesting level with

if (span && span.references.length) {
   // nested logic
}

replace it with

if (!(span && span.references.length)) {
   return
}

Jaeger backend version

No response

SDK

No response

Pipeline

No response

Stogage backend

No response

Operating system

No response

Deployment model

No response

Deployment configs

No response

@yurishkuro
Copy link
Member Author

cc @GLVSKiriti

@yurishkuro yurishkuro changed the title [Bug]: [Bug]: Prevent Critical Path code from throwing exceptions Sep 12, 2023
@GLVSKiriti
Copy link
Contributor

GLVSKiriti commented Sep 12, 2023

                |----parent----|
         |------------child------------|

I think the error is due to this undhandled case.
So default case throws the range error

@GLVSKiriti
Copy link
Contributor

I will make a PR !!

@yurishkuro
Copy link
Member Author

Thanks for the extra fix. But I still want to refactor that code to never throw exceptions

@GLVSKiriti
Copy link
Contributor

Thanks for the extra fix. But I still want to refactor that code to never throw exceptions

Can't we remove the default case bcz as already we handled all permutations of the parent and child?

@yurishkuro
Copy link
Member Author

I think the way the code is written now it's very difficult to judge if it covers all of your decision space. If it was structured as nested if statements with one condition in each, there would be easier way to reason.

Separately, even in the current code, instead of raising error from default clause it could simply log a warning with the values of the relevant timestamps. But it's still lazy approach, a proper coverage of decision space is better.

Btw we could also use fuzzing test to verify that default clause can never be reached.

yurishkuro pushed a commit that referenced this issue Sep 14, 2023
…ns (#1785)

Resolves #1779 

In this PR switch statement is refactored to if-else block and covered
all of our decision space.

---------

Signed-off-by: GLVS Kiriti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants