0

In SSH session 1, I have ran operation to create partial index in MongoDB as follows:

db.scores.createIndex(
...                       { event_time: 1, "writes.k": 1 },
...                       { background: true,
...                         partialFilterExpression: {
...                           "writes.l_at": null,
...                           "writes.d_at": null
...                         }});

The creation of the index is quite large and lasts about 30+ minutes. While it is still running I started SSH session 2.

In SSH session 2 to cluster, I described indexes on my collection scores, and it looks like it is already there...

db.scores.getIndexes()
[
 ...,
  {
    "v" : 1,
    "key" : {
        "event_time" : 1,
        "writes.k" : 1
    },
    "name" : "event_time_1_writes.k_1",
    "ns" : "leaderboard.scores",
    "background" : true,
    "partialFilterExpression" : {
        "writes.l_at" : null,
        "writes.d_at" : null
    }
 }
]

When trying to count with hint to this index, I get below error:

db.scores.find().hint('event_time_1_writes.k_1').count()
2019-02-06T22:35:38.857+0000 E QUERY    [thread1] Error: count failed: {
"ok" : 0,
"errmsg" : "error processing query: ns=leaderboard.scoresTree: $and\nSort: {}\nProj: {}\n planner returned error: bad hint",
"code" : 2,
"codeName" : "BadValue"
} : _getErrorWithCode@src/mongo/shell/utils.js:25:13
DBQuery.prototype.count@src/mongo/shell/query.js:383:11
@(shell):1:1

Never seen this below, but need confirmation to check if its failing because indexing is still running ?

Thanks!

azec-pdx
  • 4,790
  • 6
  • 56
  • 87
  • Do you see the same error after the index has finished building? – kevinadi Feb 06 '19 at 23:05
  • @KevinAdistambha, how did you guess? Unfortunately yes - index has completed in SSH session 1 after 1+h and now when I run same query I see same error, although it seems like everything was indexed. What is the reason? – azec-pdx Feb 06 '19 at 23:37
  • Just a guess, but since you're building the index in the background, it is possible that it's still going after 1+ hr. I only have ever seen that message when the index does not exist. Can you try running `db.scores.getIndexes()` in SSH session 2 and double check that the index exists? – kevinadi Feb 07 '19 at 00:48
  • @KevinAdistambha, index creation has completed in SSH session 1 after an hour +/- few minutes. When I ran this query `db.scores.find().hint('event_time_1_writes.k_1').count()` it was throwing that error again. Now it has stabilized and just hangs when I ran same... Output from `db.scores.getIndexes()` shows that my index is correctly created. – azec-pdx Feb 07 '19 at 00:51
  • This is strange. What MongoDB version are you using, what's the topology of the deployment (standalone, replica set, sharded cluster)? Could you try the same when you run the shell with `mongo --norc`? How about `hint({event_time:1, "writes.k":1})` e.g. use the index spec instead of its name? Finally, is it possible for you to test this using the latest MongoDB version (4.0.5)? – kevinadi Feb 07 '19 at 01:06

0 Answers0