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

feat: Add document delete mechanics #1263

Merged
merged 18 commits into from
Apr 2, 2023
Merged

Conversation

fredcarle
Copy link
Collaborator

@fredcarle fredcarle commented Mar 30, 2023

Relevant issue(s)

Resolves #1262
Resolves #867

Description

This PR covers deleting (not purging) of documents. It adds a status value to the composite block and allows the merkle DAG to keep track of deleted documents. It also moves the fields from value instances to deleted instances to easily filter deleted documents and avoid extra overhead from the deleted documents on normal queries. We can thus select to show deleted documents when querying and are able to show the status of the document (_isDeleted: true/false) in the response.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

(replace) Describe the tests performed to verify the changes. Provide instructions to reproduce them.

Specify the platform(s) on which this was tested:

  • (modify the list accordingly)
  • Arch Linux
  • Debian Linux
  • MacOS
  • Windows

@fredcarle fredcarle self-assigned this Mar 30, 2023
@fredcarle fredcarle added action/no-benchmark Skips the action that runs the benchmark. area/query Related to the query component area/datastore Related to the datastore / storage engine system area/parser Related to the parser components area/crdt Related to the (Merkle) CRDT system area/p2p Related to the p2p networking system area/mapper Related to the mapper components area/planner Related to the planner system labels Mar 30, 2023
@fredcarle fredcarle requested a review from a team March 30, 2023 17:23
@@ -307,6 +308,14 @@ func (n *selectNode) initFields(selectReq *mapper.Select) ([]aggregateNode, erro
//nolint:errcheck
n.addTypeIndexJoin(f) // @TODO: ISSUE#158
Copy link
Contributor

Choose a reason for hiding this comment

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

way out of scope, but I just noticed this is not linked to an open ticket, but the one partially responsible for its introduction. We need to open a ticket for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

planner/scan.go Outdated Show resolved Hide resolved
client/collection.go Outdated Show resolved Hide resolved
client/document.go Outdated Show resolved Hide resolved
client/document.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

Got a few items that I think should be discussed before merge.

I'm sorry as I feel like you checked in with me on this quite early, I misunderstood you then without realising and now it is needed to be talked about within the PR.

I haven't fully reviewed the internals/tests for this either, I'll go over them once we've all agreed on the high level discussion items.

Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

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

Some issues/thoughts.

Haven't gone through everything yet, but I need to go to sleep :D

Ill ping when im up and we can keep progressing.

client/document.go Outdated Show resolved Hide resolved
client/request/status.go Outdated Show resolved Hide resolved
db/collection_delete.go Outdated Show resolved Hide resolved
db/collection_delete.go Outdated Show resolved Hide resolved
db/collection_delete.go Outdated Show resolved Hide resolved
tests/integration/mutation/simple/delete/single_id_test.go Outdated Show resolved Hide resolved
core/crdt/composite.go Outdated Show resolved Hide resolved
@fredcarle fredcarle force-pushed the fredcarle/feat/document-delete branch from eef6249 to 40765a0 Compare March 31, 2023 22:33
db/collection.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 1, 2023

Codecov Report

Merging #1263 (7dd4293) into develop (b9d2e32) will decrease coverage by 0.05%.
The diff coverage is 69.52%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1263      +/-   ##
===========================================
- Coverage    70.27%   70.22%   -0.05%     
===========================================
  Files          184      184              
  Lines        17700    17791      +91     
===========================================
+ Hits         12438    12494      +56     
- Misses        4324     4346      +22     
- Partials       938      951      +13     
Impacted Files Coverage Δ
client/request/select.go 100.00% <ø> (ø)
core/doc.go 96.72% <ø> (ø)
db/errors.go 81.17% <ø> (ø)
db/fetcher/encoded_doc.go 61.87% <ø> (-0.28%) ⬇️
planner/mapper/targetable.go 72.97% <0.00%> (-2.03%) ⬇️
planner/planner.go 77.85% <ø> (ø)
core/crdt/composite.go 61.53% <38.63%> (-14.47%) ⬇️
db/collection.go 68.26% <60.78%> (-0.59%) ⬇️
core/crdt/lwwreg.go 75.25% <70.00%> (-1.41%) ⬇️
db/fetcher/fetcher.go 62.88% <70.27%> (+1.92%) ⬆️
... and 13 more

... and 4 files with indirect coverage changes

@fredcarle fredcarle force-pushed the fredcarle/feat/document-delete branch from c5d1254 to f77bb70 Compare April 1, 2023 03:22
@fredcarle fredcarle added the feature New feature or request label Apr 1, 2023
@fredcarle fredcarle added this to the DefraDB v0.5 milestone Apr 1, 2023
@fredcarle fredcarle force-pushed the fredcarle/feat/document-delete branch from f77bb70 to ef651b7 Compare April 1, 2023 16:38
Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

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

Really great stuff! Super excited to see this land.

Small number of todos/suggestions, few more questions/thoughts.

Going to approve now, so you dont need to play another round of reviewer ping pong, but do go through the various issues 👍

core/delta.go Outdated Show resolved Hide resolved
db/collection.go Outdated Show resolved Hide resolved
db/collection.go Outdated Show resolved Hide resolved
db/collection.go Show resolved Hide resolved
db/collection.go Outdated Show resolved Hide resolved
db/fetcher/fetcher.go Outdated Show resolved Hide resolved
db/fetcher/fetcher.go Outdated Show resolved Hide resolved
db/fetcher/fetcher.go Show resolved Hide resolved
planner/delete.go Outdated Show resolved Hide resolved
request/graphql/parser/query.go Show resolved Hide resolved
@fredcarle fredcarle force-pushed the fredcarle/feat/document-delete branch from 68b4fd1 to 9bdac20 Compare April 2, 2023 21:32
@fredcarle fredcarle force-pushed the fredcarle/feat/document-delete branch from 5063e33 to da7d94f Compare April 2, 2023 22:23
@fredcarle fredcarle dismissed AndrewSisley’s stale review April 2, 2023 23:09

requested changes covered

@fredcarle fredcarle merged commit 5cd9d18 into develop Apr 2, 2023
@fredcarle fredcarle deleted the fredcarle/feat/document-delete branch April 2, 2023 23:10
shahzadlone pushed a commit that referenced this pull request Apr 13, 2023
This PR covers deleting (not purging) of documents. It adds a status value to the composite block and allows the merkle DAG to keep track of deleted documents. It also moves the fields from value instances to deleted instances to easily filter deleted documents and avoid extra overhead from the deleted documents on normal queries. We can thus select to show deleted documents when querying and are able to show the status of the document (_isDeleted: true/false) in the response.
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
This PR covers deleting (not purging) of documents. It adds a status value to the composite block and allows the merkle DAG to keep track of deleted documents. It also moves the fields from value instances to deleted instances to easily filter deleted documents and avoid extra overhead from the deleted documents on normal queries. We can thus select to show deleted documents when querying and are able to show the status of the document (_isDeleted: true/false) in the response.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/crdt Related to the (Merkle) CRDT system area/datastore Related to the datastore / storage engine system area/mapper Related to the mapper components area/p2p Related to the p2p networking system area/parser Related to the parser components area/planner Related to the planner system area/query Related to the query component feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add delete mechanics P2P broadcasting does not handle doc deletions
4 participants