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

Fix too many relationship error #5541

Merged
merged 2 commits into from
Jan 22, 2025
Merged

Conversation

LucasG0
Copy link
Contributor

@LucasG0 LucasG0 commented Jan 21, 2025

Fixes #5474, #5475

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Jan 21, 2025
Copy link

codspeed-hq bot commented Jan 21, 2025

CodSpeed Performance Report

Merging #5541 will not alter performance

Comparing lgu-fix-prefix-too-many-rels (aa1860d) with stable (21db17a)

Summary

✅ 10 untouched benchmarks

@LucasG0 LucasG0 force-pushed the lgu-fix-prefix-too-many-rels branch from eaa8f89 to ef1adef Compare January 21, 2025 19:19
# having the same parent, with the parent having another extra relationship. Concurrent coroutines will try to
# add this relationship to this object, and the second one will fail. See https://github.com/opsmill/infrahub/issues/5474.
# Note it also prevents extra relationships fetching. Ideally, DataLoader would fetch all needed data only once
# and exporting node to graphql would then not mutate this object.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Additional thoughts regarding why ip_namespace relationships of parent prefix is not used from DataLoader in below test, based on debugging/discussion with @ajtmccarty. I am not 100% sure but I believe it makes sense:

  • DataLoader correctly loads prefix 10.0.0.0/8, but when we resolve parent of 10.0.0.0/16 (ie, 10.0.0.0/8), node_fields appear to be different between first call to _get_entities_with_data_loader for 10.0.0.0/8 and second call to resolve parent of 10.0.0.0/16 (ie, 10.0.0.0/8). Thus we do not match existing DataLoader and cannot retrieve existing node already having ip_namespace fetched.
  • Now, if we had queried only 10.0.0.0/16 and 10.0.0.1/16, 10.0.0.0/8 would have been retrieved only while resolving parent of these nodes. However, graphql query does not ask for parent ip_namespace relationship so it's not retrieved by DataLoader, but it does ask for hfid which relies on ip_namespace and then we fetch it after DataLoader step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update as per @ajtmccarty slack comment, ip_namespace is probably not retrieved correctly because we resolve parent with kind BuiltinIPPrefix for which hfid does not contain ip_namespace, instead of InfraPrefix

@LucasG0 LucasG0 requested a review from a team January 21, 2025 19:37
Copy link
Collaborator

@dgarros dgarros left a comment

Choose a reason for hiding this comment

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

Great work, it was a tough one
please can you add a news fragment to include something in the release note

@LucasG0 LucasG0 merged commit ee9b3e7 into stable Jan 22, 2025
36 checks passed
@LucasG0 LucasG0 deleted the lgu-fix-prefix-too-many-rels branch January 22, 2025 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Unhandled exception when a BuiltinIPAddress have 2 BuiltinIPPrefix
3 participants