Could not delete node by uid. Message is Success, but node is still there. Slash returns different types then Ratel

I have type User and Material.

type User {
//...
    materials: [Material]
}
type Material {
    id: ID!
    name: String!

I created some node with error, having Material.name being null

Now I wanted to delete that node using Ratel. I found the id (or uid of that bad material) and wrote mutation

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

The message is success, but when I search for that node, the node is not deleted.
Now my queries are problematic because Slash can not fetch String! field with null as its value, and I wanted to delete it by hand, Ratel is saying that the mutation is Done, but nothing changes.

The weird thing as well is that, when I query it from Slash with __typename, the bad-constructed material is of type Material, but when I search it from the Ratel with

{
	q(func: type("Material")) {
    uid
  }
}

The result is:

{
  "data": {
    "q": [
      {
        "uid": "0x3d0cd"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 57404,
      "processing_ns": 281996,
      "encoding_ns": 35332,
      "assign_timestamp_ns": 587825,
      "total_ns": 1010259
    },
    "txn": {
      "start_ts": 460282
    },
    "metrics": {
      "num_uids": {
        "_total": 1,
        "dgraph.type": 0,
        "uid": 1
      }
    }
  }
}

As you can see, the material with bad data is not there. I searched it by uid, found it and tried expand(all), tried to print a type, nothing. It only shows the uid of that bad node. How can I fix it?

That’s how it works. The UID will remain there cuz this is a design thing. If there’s no data, It is in fact deleted.

Things to notice in your post

You have deleted 0x382d0 and you are searching for 0x3d0cd, two different UIDs.

Maybe you thought that you could delete child nodes by deleting the parent? dunno, if so, that’s not possible like this.

Let me go step by step
Query:
query user { queryUser{ materials{ id } } }

Returned result:

{
  "data": {
    "queryUser": [
      {
        "materials": [
          {
            "id": "0x382d0"
          },
          {
            "id": "0x3d0cd"
          }
        ]
      },
      {
        "materials": []
      }
    ]
  },
  "extensions": {
    "touched_uids": 6,
    "tracing": {
      "version": 1,
      "startTime": "2021-01-14T19:29:19.941388426Z",
      "endTime": "2021-01-14T19:29:19.942846579Z",
      "duration": 1458174,
      "execution": {
        "resolvers": [
          {
            "path": [
              "queryUser"
            ],
            "parentType": "Query",
            "fieldName": "queryUser",
            "returnType": "[User]",
            "startOffset": 88019,
            "duration": 1342184,
            "dgraph": [
              {
                "label": "query",
                "startOffset": 133298,
                "duration": 1262802
              }
            ]
          }
        ]
      }
    }
  }
}

Now, I take the id of the one I know is incorrect 0x382d0
I go to Run DQL Query, that opens Ratel UI right? I choose mutations and write:

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

Returned message is success, but when I run the query above again, the incorrect node still appears.
Further more, if I query it by type, the node with uid 0x382d0 does not have type Material, but it is still returned on material query. I am at the beginning of development, and it is not a real problem for me to drop the whole database. But my problem is, if this happens during production, what should I do?

could this be a problem with the mutation not being committed?

https://dgraph.io/docs/mutations/mutations-using-curl/

Don’t remember the correct process to flag commit in Ratel.

In Ratel is commitNow=true by default.

1 Like