Query does not work in both directions

I am encountering a scenario in which I search for a specific edge between two nodes. But when I do a search in the opposite direction it does not always work.

For example:

{
	q(func: eq(_stp_id, "Track:/m/0101lf9")) @filter(has(On))  {
		_stp_id		
		<On> @filter(eq(_stp_id, "Album:/m/0101f9x")) {
                   _stp_id
                }
	}
    
	q2(func: eq(_stp_id, "Album:/m/0101f9x")) @filter(has(<~On>)) @cascade {
		_stp_id		
		<~On> @filter(eq(_stp_id, "Track:/m/0101lf9")) {
                    _stp_id
                 }
	}    
}

Returns the target node only using the reverse edge.

 "data": {
    "q": [
      {
        "_stp_id": "Track:/m/0101lf9"
      }
    ],
    "q2": [
      {
        "_stp_id": "Album:/m/0101f9x",
        "~On": [
          {
            "_stp_id": "Track:/m/0101lf9"
          }
        ]
      }
    ]
  }

Sometimes, depending on the nodes the opposite is true. It returns for <On> but not <~On>.

Anyone know why this would be?

Strangely enough if I create another field w/ an id that does not include type info it works:

{
	q(func: eq(_stp_label, "/m/0101lf9")) @filter(has(On))  {
		_stp_id		
                _stp_label
		<On> @filter(eq(_stp_label, "/m/0101f9x")) {
                   _stp_id
                   _stp_label
                }
	}
    
	q2(func: eq(_stp_id, "Album:/m/0101f9x")) @filter(has(~On)) @cascade {
		_stp_id		
                _stp_label
		<~On> @filter(eq(_stp_id, "Track:/m/0101lf9")) {
                    _stp_id
                    _stp_label
                 }
	}    
}

Results:

{
  "data": {
    "q": [
      {
        "_stp_id": "Track:/m/0101lf9",
        "_stp_label": "/m/0101lf9",
        "On": [
          {
            "_stp_id": "Album:/m/0101f9x",
            "_stp_label": "/m/0101f9x"
          }
        ]
      }
    ],
    "q2": [
      {
        "_stp_id": "Album:/m/0101f9x",
        "_stp_label": "/m/0101f9x",
        "~On": [
          {
            "_stp_id": "Track:/m/0101lf9",
            "_stp_label": "/m/0101lf9"
          }
        ]
      }
    ]
  },

Indexing is the same for both of these:

 <_stp_id>: string @index(exact) .
 <_stp_label>: string @index(exact) .

So it seems both should return the same results.

I can’t get what is happening by reading this topic. If you give me a reproducible way we can work on it.

From my side, I see that reverse edges are working normaly.

Please share more details about your context. The version used, the system used, and samples that can be replicated (tested by different people).

If you have a question, I can help, but if you suspect it is a bug. You can fill up an issue with all the details of the case or we can (through contextualization) debug step by step. And determine whether it is a bug or not.

Cheers.

I reloaded my data and it is no longer happening.

We are evaluating different graph databases using a test harness. The test this scenario comes from just searches for the existence of an edge between a set of 10,000 source\target nodes. Out of 10,000 Dgraph is not finding 900 or so so I narrowed it down to this scenario.

The q and q2 queries posted above are just tests to see if a edge exists between two unique nodes. One is a test traversing forward the other in reverse. The reverse one worked, so the edge does exist. The forward traversal did not for some reason.

This is using v1.2.2 in a docker container. Again, I reloaded and cannot reproduce it right now but will keep an eye open as it did happen.

Hi Luke,

Thanks for reporting this.
Fixed in v20.03.1 and v1.2.3 (PR).