-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.2.1, 2.4.5
-
Component/s: Index Maintenance
-
None
-
Environment:Windows 7, CentOS, Mac OS
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I have a document with a field "ia", it's a HashMap (with key value pair) in my java entity.
The mongo document PlayerAttribute looks like this:
{
"_id" : ObjectId("51f8c4cbcd757bd40da8a0c6"),
"gameId" : "XYZ",
"ia" : {
"CrashesCount" : "0",
"HardCurrencyOwned" : "7898",
"LastNotificationsId" : "12",
"Level" : "11",
"PvpRacesPlayed" : "0",
"PvpRaiting_FreeStyle" : "1200",
"PvpRaiting_Motocross" : "1200",
"PvpRaiting_SpeedAndStyle" : "1200",
"PvpRaiting_StepUp" : "1200",
"PvpRank" : "0"
},
"lastSessionExpireTime" : ISODate("2013-07-31T12:31:33.966Z"),
"lastSessionStartTime" : ISODate("2013-07-31T12:31:27.975Z"),
"name" : "abc123",
type : null
}
This is the index definition for the collection,
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "player.PlayerAttribute",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"effectiveDate" : 1
},
"ns" : "player.PlayerAttribute",
"name" : "effectiveDate",
"dropDups" : false,
"sparse" : false
},
{
"v" : 1,
"key" : {
"endDate" : 1
},
"ns" : "player.PlayerAttribute",
"name" : "endDate",
"dropDups" : false,
"sparse" : false
},
{
"v" : 1,
"key" : {
"gameId" : 1,
"name" : 1
},
"unique" : true,
"ns" : "player.PlayerAttribute",
"name" : "pa_gid_n_unique_idx"
},
{
"v" : 1,
"key" : {
"gameId" : 1,
"ia" : 1,
"name" : 1
},
"ns" : "player.PlayerAttribute",
"name" : "pa_gid_iattr_n_idx"
},
{
"v" : 1,
"key" : {
"gameId" : 1,
"lastSessionExpireTime" : 1
},
"ns" : "player.PlayerAttribute",
"name" : "pa_gid_lset_idx"
}
]
This is the query I used from mongo shell,
db.PlayerAttribute.find({"gameId":"XYZ", "attributes.CrashesCount" : "0"}).count();
First time it gives me the result greater than zero (but that is incorrect. For eg., if there are 7 docs match the query, it would say 6) and the next subsequent times it gives 0 and this happens for 5 to 10 minutes.
After about 5 to 10 minutes, it gives the non zero number again (one time) and next few times it is zero.
When I deleted this index ("name" : "pa_gid_iattr_n_idx"), it gives correct count all the time.
Any idea why this index on hashmap field ("name" : "pa_gid_iattr_n_idx") makes mongo to produce incorrect and inconsistent result?
Thanks in advance for the response.