Match query with while: max depth seems to be going in infinite loop

Was trying to find the number of members of a group in active directory. Group can be member of group so there are chances of cyclic membership. I thought orientdb could handle that but the query seems to be going in infinite loop. Any ideas how to fix this?

Hi @mukesh

MATCH statement with WHILE condition does not check already traversed nodes, so you can definitely go in an infinite loop (TRAVERSE does, but it’s a completely different statement).
My suggestion is to set a WHILE condition or a reasonable MAXDEPTH, that should avoid the infitite loop.
If you already tried it or if I’m missing something, could you please post a reproducer?

Thanks

Luigi

I was trying to use a smarter way to do this instead of relying on just depth. There are cases where i have depth 6/7. But 99% of the others don’t have it. So it’s a huge waste for me to traverse the same paths. I tried a few things but it doesn’t seem to work. Basically am trying to say that the current node should not be part of the path, if it is then stop that traversal.

MATCH {CLASS: Group, as: grp}
    .in('is_member_of')
        {AS: member, maxDepth: 5, pathAlias: pa, where: ($depth >= 1), while: ($currentMatch not in $matched.pa)}
RETURN grp.@rid, $matched.pa

If you want to try it out:-

CREATE CLASS Group EXTENDS V;
CREATE PROPERTY Group.name STRING (MANDATORY TRUE, NOTNULL TRUE);
CREATE INDEX Group.name ON Group (name COLLATE ci) UNIQUE;

CREATE CLASS is_member_of EXTENDS E;
CREATE PROPERTY is_member_of.out LINK V;
CREATE PROPERTY is_member_of.in LINK Group;
CREATE INDEX is_member_of.unique_member ON is_member_of (out, in) UNIQUE;


INSERT INTO Group SET name = 'A';
INSERT INTO Group SET name = 'B';
INSERT INTO Group SET name = 'C';
INSERT INTO Group SET name = 'D';
INSERT INTO Group SET name = 'E';

CREATE EDGE is_member_of FROM (SELECT FROM Group where name = 'B') TO (SELECT FROM Group where name = 'A');
CREATE EDGE is_member_of FROM (SELECT FROM Group where name = 'C') TO (SELECT FROM Group where name = 'B');
CREATE EDGE is_member_of FROM (SELECT FROM Group where name = 'D') TO (SELECT FROM Group where name = 'B');
CREATE EDGE is_member_of FROM (SELECT FROM Group where name = 'E') TO (SELECT FROM Group where name = 'D');
CREATE EDGE is_member_of FROM (SELECT FROM Group where name = 'A') TO (SELECT FROM Group where name = 'E');

wow. this community is really dead. OrientDB was really looking promising but seems to have too many weird issues stiff and community support is almost not there.

Hi @mukesh

sorry for the late reply, I need to find a moment to test it and see what the problem is.
I’ll try to do it ASAP

Thanks

Luigi

Sure Luigi, really appreciate you taking interest and giving your time to this.
My message wasn’t meant to be personal. I meant more as a overall community involvement, which makes it difficult as a user.

Hi @mukesh

No worries, feedback is always appreciated :wink:

I had a chance to check the query, it seems it needs a little fix. I added it to my backlog, hopefully it won’t take too long. I’ll keep you posted

Thanks

Luigi

Thanks Luigi. Look forward to the fix. It will really speed up all my queries. We have over 20MM edge so this starts mattering a lot.

Was wondering if you had some ETA on this?