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 bug when materialising documents containing (non-existent) pinned relations #177

Merged
merged 20 commits into from
Jun 29, 2022

Conversation

sandreae
Copy link
Member

@sandreae sandreae commented Jun 28, 2022

When the materialiser comes across a pinned relations it kicks off a reduce task for each document view being related to. This is the correct behaviour. But then our clever reduce task was freaking out if there was no document for the requested document view already in the store. This is buggy behaviour. This PR fixes it by not critically failing the task but instead exiting the task silently. Also adds a test for this case.

branch includes unmerged changes from: #175 + #176

📋 Checklist

  • Add tests that cover your changes
  • Add this PR to the Unreleased section in CHANGELOG.md
  • Link this PR to any issues it closes
  • New files contain a SPDX license header

@codecov
Copy link

codecov bot commented Jun 28, 2022

Codecov Report

Merging #177 (4983d5c) into main (07235c8) will increase coverage by 0.01%.
The diff coverage is 89.92%.

@@            Coverage Diff             @@
##             main     #177      +/-   ##
==========================================
+ Coverage   90.53%   90.55%   +0.01%     
==========================================
  Files          43       43              
  Lines        2885     2985     +100     
==========================================
+ Hits         2612     2703      +91     
- Misses        273      282       +9     
Impacted Files Coverage Δ
aquadoggo/src/materializer/tasks/dependency.rs 94.47% <65.51%> (-4.90%) ⬇️
aquadoggo/src/materializer/tasks/reduce.rs 90.22% <85.71%> (+0.45%) ⬆️
aquadoggo/src/db/stores/test_utils.rs 97.77% <100.00%> (ø)
aquadoggo/src/materializer/service.rs 97.10% <100.00%> (+2.54%) ⬆️
aquadoggo/src/materializer/worker.rs 90.04% <0.00%> (-0.42%) ⬇️

Continue to review full report at Codecov.

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

Comment on lines +25 to +31
let document_id = match resolve_document_id(&context, &input).await? {
Some(document_id) => Ok(document_id),
None => {
debug!("No document found for this view, exit without dispatching any other tasks");
return Ok(None);
}
}?;
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of returning Ok(None) when a document for a requested view didn't exist, we were critically failing the task here.

Logic bug....

@sandreae sandreae marked this pull request as ready for review June 28, 2022 12:55
@sandreae sandreae changed the title Materializer integration test Fix bug when materialising views containing pinned relations Jun 28, 2022
@sandreae sandreae changed the title Fix bug when materialising views containing pinned relations Fix bug when materialising documents containing (non-existent) pinned relations Jun 28, 2022
@sandreae
Copy link
Member Author

I think the test coverage drops here because all the debug!() lines add more untested lines when logging after a critical db error is found. We don't test these cases right now as they're hard to simulate. We could use mocking for this I recon.

@adzialocha adzialocha changed the base branch from development to main June 28, 2022 21:31
@sandreae sandreae requested a review from adzialocha June 28, 2022 21:53
@adzialocha adzialocha merged commit d3c4df4 into main Jun 29, 2022
@adzialocha adzialocha deleted the materializer-integration-test branch June 29, 2022 14:10
adzialocha added a commit that referenced this pull request Jul 1, 2022
* main:
  Update CHANGELOG.md
  Refactor replication API (#184)
  GraphQL replication client (#137)
  Update aquadoggo to v0.3.0 in aquadoggo_cli
  v0.3.0
  Prepare CHANGELOG for v0.3.0 release
  Commit Cargo.lock
  p2panda-rs v0.4.0
  Remove unused import
  Update naming in `publishEntry` query and `nextEntryArgs` response (#181)
  Fix bug when materialising documents containing (non-existent) pinned relations (#177)
  Logging in reduce task (#175)
  Refactor test db creation (#176)
adzialocha added a commit that referenced this pull request Jul 1, 2022
* schema-provider:
  Minor clean ups
  Move to unreleased section in CHANGELOG
  Update CHANGELOG.md
  Refactor replication API (#184)
  GraphQL replication client (#137)
  Update aquadoggo to v0.3.0 in aquadoggo_cli
  v0.3.0
  Prepare CHANGELOG for v0.3.0 release
  Commit Cargo.lock
  p2panda-rs v0.4.0
  Remove unused import
  Update naming in `publishEntry` query and `nextEntryArgs` response (#181)
  Fix bug when materialising documents containing (non-existent) pinned relations (#177)
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.

Materializer crashes processing operations with pinned relations to non-existent views
2 participants