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: Infinite loop when updating one-one relation #1915

Merged

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #1914

Description

Fixes an a bug where an infinite loop may be created when updating a self-referencing one-one relation from the secondary side.

The first commit documents the bug, the second commit fixes it.

@AndrewSisley AndrewSisley added bug Something isn't working area/query Related to the query component labels Sep 27, 2023
@AndrewSisley AndrewSisley added this to the DefraDB v0.8 milestone Sep 27, 2023
@AndrewSisley AndrewSisley requested a review from a team September 27, 2023 20:10
@AndrewSisley AndrewSisley self-assigned this Sep 27, 2023
If the relationship references the same (host) collection, the function would in some circumstances return the known field.  In collection.save, when updating via a secondary one-one field this leads to an infinite loop.
AndrewSisley added a commit to AndrewSisley/defradb that referenced this pull request Sep 27, 2023
Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

Cheers for sorting

@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (2c862ac) 70.80% compared to head (5eb4343) 70.84%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1915      +/-   ##
===========================================
+ Coverage    70.80%   70.84%   +0.04%     
===========================================
  Files          233      233              
  Lines        24322    24334      +12     
===========================================
+ Hits         17220    17238      +18     
+ Misses        5930     5926       -4     
+ Partials      1172     1170       -2     
Flag Coverage Δ
all-tests 70.84% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
client/descriptions.go 73.33% <100.00%> (-0.35%) ⬇️
db/collection.go 73.07% <100.00%> (ø)
db/collection_update.go 60.00% <100.00%> (+0.43%) ⬆️
planner/type_join.go 74.66% <100.00%> (+0.63%) ⬆️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c862ac...5eb4343. Read the comment docs.

@AndrewSisley AndrewSisley merged commit e952be5 into sourcenetwork:develop Sep 27, 2023
14 checks passed
@AndrewSisley AndrewSisley deleted the 1914-one-one-infinite-loop branch September 27, 2023 22:26
shahzadlone pushed a commit that referenced this pull request Oct 2, 2023
## Relevant issue(s)

Resolves #1914 

## Description

Fixes an a bug where an infinite loop may be created when updating a
self-referencing one-one relation from the secondary side.
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
## Relevant issue(s)

Resolves sourcenetwork#1914 

## Description

Fixes an a bug where an infinite loop may be created when updating a
self-referencing one-one relation from the secondary side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite loop when updating one-one self-ref. relation field
2 participants