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]: Unable to Completely Delete Nodes or Whole Graph in Dgraph #9213

Open
imrahul361 opened this issue Nov 7, 2024 · 4 comments
Open
Labels
kind/bug Something is broken.

Comments

@imrahul361
Copy link

imrahul361 commented Nov 7, 2024

Description

I am encountering an issue with Dgraph where I am unable to fully delete a node or the entire graph. Although I can delete individual predicates from a node, complete node deletion using either the JSON mutation syntax or RDF N-Quad format does not seem to work as expected. Instead of being fully removed, nodes turn into orphan nodes with no data but still apparently occupy space on disk.

Attempts to Delete a Node

JSON Mutation Query

{
  "delete": {
    "uid": "0x37..."
  }
}

RDF N-Quad Format

{
  delete {
    <0x37...> * * .
  }
}

In both scenarios, I am consistently facing issues with Dgraph where efforts to completely delete nodes using JSON mutations do not work as intended. Despite receiving a "done" success message, the node remains unaffected.

Deleting all predicates one by one from a node

{
  delete {
    <0x37...> <name> * .
    <0x37...> <age> * .
   .
   .
   .
   .
  }
}

In the above case, the nodes are not entirely removed; they simply become empty objects. When I query these nodes post attempted deletion, they appear as empty or orphaned nodes, indicating that although their predicates have been cleared, the nodes themselves linger.

Environment Details

Dgraph Version: v24.0.1
Deployment: Standalone
RAM: 8GB
Disk Setup: HDD, 50GB
Number of Alpha Nodes: 3
Number of Zero Nodes: 3
Operating System: Debian GNU/Linux 12 (bookworm)
CPU: 2 cores

Requirement

The requirement is that when a node is deleted, not only should all its predicates be deleted but it should also be entirely removed from the disk to not waste space and possibly affect performance. This behavior is crucial for managing dynamic graphs where nodes are frequently created and deleted.

Please let me know if there are additional configurations or methods that should be followed to completely delete nodes and free up all associated resources, or if this might be a potential bug that needs addressing this memory leak.

Any assistance or clarification on this issue would be greatly appreciated, as it impacts our ability to efficiently manage storage and maintain the graph's integrity.

Thank you!

Tell us a little more about your go-environment?

Go version 1.20.2

Have you tried reproducing the issue with the latest release?

None

What is the hardware spec (RAM, CPU, OS)?

Dgraph Version: v24.0.1
Deployment: Standalone
RAM: 8GB
Disk Setup: HDD, 50GB
Number of Alpha Nodes: 3
Number of Zero Nodes: 3
Operating System: Debian GNU/Linux 12 (bookworm)
CPU: 2 cores

What steps will reproduce the bug?

Create a node, Let's say:

{
 "set" : {
   "name" : "xyz",
   "age" : 20,
   "city" : mumbai
  }
}

On success, it will create an uid. let's say <0x123...>

Get the Details:

{
  response(func: uid(0x123...)) {
   	name
   	age
   	city
  }
}

Delete the Node:

{
  delete {
    <0x123...> * * .
  }
}

Deleting all predicates one by one from a node

{
  delete {
    <0x123...> <name> * .
    <0x123...> <age> * .
   .
   .
   .
   .
  }
}

Expected behavior and actual result.

Expected Behavior:

The object with uid <0x123...> should no longer exist.

Actual Behavior:

  1. The node remains unaffected despite the successful message "done".
  2. The result is an empty object devoid of any predicates.

Additional information

No response

@imrahul361 imrahul361 added the kind/bug Something is broken. label Nov 7, 2024
@harshil-goel
Copy link
Contributor

What do you mean object shouldn't exists? In Dgraph UID is just a identifier. It's uint64, and all the UIDs are technically empty objects in which you are adding some data. UIDs don't get deleted, you can keep reusing them.

@imrahul361
Copy link
Author

Is there a more efficient way to delete nodes in Dgraph than removing all predicates to empty the object? If I only have the UID of the root node, is it possible to delete the entire graph? What is the optimal approach to delete an entire graph in Dgraph given the root node's UID?

@imrahul361
Copy link
Author

What do you mean object shouldn't exists? In Dgraph UID is just a identifier. It's uint64, and all the UIDs are technically empty objects in which you are adding some data. UIDs don't get deleted, you can keep reusing them.

{
delete {
<0x123...> * * .
}
}

using this Mutation query, I am unable to empty the object/node

@asta331
Copy link

asta331 commented Nov 12, 2024

You can use the type feature to specify predicates of a given node: https://dgraph.io/docs/dql/dql-schema/#node-types
The reason your delete mutation doesn't work is because dgraph doesn't know which predicates the node has.
I don't think this is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something is broken.
Development

No branches or pull requests

4 participants