0 Replies Latest reply on Aug 28, 2017 9:10 PM by cfb3ee69-9fb0-4fe4-a509-9d836763388c

    Duplicate Results from Query on Secondary Index

    cfb3ee69-9fb0-4fe4-a509-9d836763388c

      I am having an issue where a sequence of SecondaryIndex.getSearchKey() and SecondaryIndex.getNextNoDup() returns duplicate results (same primary key and data). I do not have a stand-alone reproducible case, but I can provide some snippets and data excerpts, below.

       

      First, here is my primary database. In this test case, it contains only a single record:

      2017-08-28 16:59:20.128 DEBUG [c.l.m.g.Graph                           ] - --- Dumping primary database ... 

      2017-08-28 16:59:20.129 DEBUG [c.l.m.g.Graph                           ] - Record #1, PK=<DatabaseEntry offset="0" size="16" data="106 83 196 184 159 24 75 240 53 66 175 214 71 210 194 237 "/> -> <DatabaseEntry offset="0" size="185" data="123 34 108 97 98 101 108 34 58 34 108 117 115 105 100 105 116 121 58 116 101 115 116 86 101 114 116 101 120 34 44 34 105 100 34 58 34 101 97 53 51 99 52 98 56 45 57 102 49 56 45 52 98 102 48 45 98 53 52 50 45 97 102 100 54 52 55 100 50 99 50 101 100 34 44 34 117 114 105 34 58 91 34 104 116 116 112 115 58 47 47 101 110 46 119 105 107 105 112 101  ... 85 bytes not shown "/> 

      2017-08-28 16:59:20.130 DEBUG [c.l.m.g.Graph                           ] - --- End of primary database dump 

       

      Next, here is a dump of my secondary database. It contains two records, both of which point to the same primary key:

      2017-08-28 16:59:20.130 TRACE [c.l.m.g.Index                           ] - --- Dumping index 'TestVertex/uri' ... 

      2017-08-28 16:59:20.133 DEBUG [c.l.m.g.Index                           ] - Index entry #1: <DatabaseEntry offset="0" size="52" data="104 116 116 112 115 58 47 47 101 110 46 119 105 107 105 112 101 100 105 97 46 111 114 103 47 119 105 107 105 47 67 97 116 101 103 111 114 121 58 67 104 105 99 97 103 111 95 66 101 97 114 115 "/> -> PK=<DatabaseEntry offset="0" size="16" data="106 83 196 184 159 24 75 240 53 66 175 214 71 210 194 237 "/> -> <DatabaseEntry offset="0" size="185" data="123 34 108 97 98 101 108 34 58 34 108 117 115 105 100 105 116 121 58 116 101 115 116 86 101 114 116 101 120 34 44 34 105 100 34 58 34 101 97 53 51 99 52 98 56 45 57 102 49 56 45 52 98 102 48 45 98 53 52 50 45 97 102 100 54 52 55 100 50 99 50 101 100 34 44 34 117 114 105 34 58 91 34 104 116 116 112 115 58 47 47 101 110 46 119 105 107 105 112 101  ... 85 bytes not shown "/> 

      2017-08-28 16:59:20.134 DEBUG [c.l.m.g.Index                           ] - Index entry #2: <DatabaseEntry offset="0" size="43" data="104 116 116 112 115 58 47 47 101 110 46 119 105 107 105 112 101 100 105 97 46 111 114 103 47 119 105 107 105 47 67 104 105 99 97 103 111 95 66 101 97 114 115 "/> -> PK=<DatabaseEntry offset="0" size="16" data="106 83 196 184 159 24 75 240 53 66 175 214 71 210 194 237 "/> -> <DatabaseEntry offset="0" size="185" data="123 34 108 97 98 101 108 34 58 34 108 117 115 105 100 105 116 121 58 116 101 115 116 86 101 114 116 101 120 34 44 34 105 100 34 58 34 101 97 53 51 99 52 98 56 45 57 102 49 56 45 52 98 102 48 45 98 53 52 50 45 97 102 100 54 52 55 100 50 99 50 101 100 34 44 34 117 114 105 34 58 91 34 104 116 116 112 115 58 47 47 101 110 46 119 105 107 105 112 101  ... 85 bytes not shown "/> 

      2017-08-28 16:59:20.134 DEBUG [c.l.m.g.Index                           ] - --- End of index dump for TestVertex/uri. 

       

      Against this environment, I execute the following query code:

      String[] uris={

         "https://en.wikipedia.org/wiki/Chicago_Bears",

         "https://en.wikipedia.org/wiki/Category:Chicago_Bears"
      };

       

      ...

       

      SecondaryDatabase secondaryDatabase=...

      for (String uri : uris)

      {

        LogHelper.trace(this, "Searching for URI='%s' ...", uri);

       

        DatabaseEntry searchEntry=new DatabaseEntry(uri.getBytes(TextEncoding.UTF8));

        DatabaseEntry pKey=new DatabaseEntry();

        DatabaseEntry pData=new DatabaseEntry();

       

        CursorConfig cursorConfig=new CursorConfig();

         try (SecondaryCursor cursor=secondaryDatabase.openCursor(null, cursorConfig))

        {

        OperationStatus status=cursor.getSearchKey(searchEntry, pKey, pData, LockMode.DEFAULT);

         int i=0;

         while (Objects.equals(status, OperationStatus.SUCCESS))

        {

        LogHelper.trace(this, "Result #%d: PK=%s, Data=%s", i+1, pKey.toString(), pData.toString());

        i++;

       

        status=cursor.getNextNoDup(searchEntry, pKey, pData, LockMode.DEFAULT);

        }

        }

      }

       

      The results are as follows:

      2017-08-28 16:59:20.134 TRACE [c.l.m.t.c.g.VertexTest                  ] - Searching for URI='https://en.wikipedia.org/wiki/Chicago_Bears' ... 

      2017-08-28 16:59:20.136 TRACE [c.l.m.t.c.g.VertexTest                  ] - Result #1: PK=<DatabaseEntry offset="0" size="16" data="106 83 196 184 159 24 75 240 53 66 175 214 71 210 194 237 "/>, Data=<DatabaseEntry offset="0" size="185" data="123 34 108 97 98 101 108 34 58 34 108 117 115 105 100 105 116 121 58 116 101 115 116 86 101 114 116 101 120 34 44 34 105 100 34 58 34 101 97 53 51 99 52 98 56 45 57 102 49 56 45 52 98 102 48 45 98 53 52 50 45 97 102 100 54 52 55 100 50 99 50 101 100 34 44 34 117 114 105 34 58 91 34 104 116 116 112 115 58 47 47 101 110 46 119 105 107 105 112 101  ... 85 bytes not shown "/> 

      2017-08-28 16:59:20.139 TRACE [c.l.m.t.c.g.VertexTest                  ] - Searching for URI='https://en.wikipedia.org/wiki/Category:Chicago_Bears' ... 

      2017-08-28 16:59:20.140 TRACE [c.l.m.t.c.g.VertexTest                  ] - Result #1: PK=<DatabaseEntry offset="0" size="16" data="106 83 196 184 159 24 75 240 53 66 175 214 71 210 194 237 "/>, Data=<DatabaseEntry offset="0" size="185" data="123 34 108 97 98 101 108 34 58 34 108 117 115 105 100 105 116 121 58 116 101 115 116 86 101 114 116 101 120 34 44 34 105 100 34 58 34 101 97 53 51 99 52 98 56 45 57 102 49 56 45 52 98 102 48 45 98 53 52 50 45 97 102 100 54 52 55 100 50 99 50 101 100 34 44 34 117 114 105 34 58 91 34 104 116 116 112 115 58 47 47 101 110 46 119 105 107 105 112 101  ... 85 bytes not shown "/> 

      2017-08-28 16:59:20.140 TRACE [c.l.m.t.c.g.VertexTest                  ] - Result #2: PK=<DatabaseEntry offset="0" size="16" data="106 83 196 184 159 24 75 240 53 66 175 214 71 210 194 237 "/>, Data=<DatabaseEntry offset="0" size="185" data="123 34 108 97 98 101 108 34 58 34 108 117 115 105 100 105 116 121 58 116 101 115 116 86 101 114 116 101 120 34 44 34 105 100 34 58 34 101 97 53 51 99 52 98 56 45 57 102 49 56 45 52 98 102 48 45 98 53 52 50 45 97 102 100 54 52 55 100 50 99 50 101 100 34 44 34 117 114 105 34 58 91 34 104 116 116 112 115 58 47 47 101 110 46 119 105 107 105 112 101  ... 85 bytes not shown "/> 

       

      Note that for the second query (time-stamp ending .139), JE returned two identical results where I would expect it to only return one result, like the first query.

       

      I have tried both "sticky" and "non-sticky" cursors, as well as Cursor.getNext() vs. cursor.getNextNoDup() with no changes in results.

       

      I am hoping that I just made a simple mistake here and having another set of eyes look at the problem will help me identify and correct it. Thanks in advance for your help!

       

      -- John