user2333312
user2333312

Reputation: 131

MongoDB - wrong type for field (expireAfterSeconds) long != int

This is for MongoDB 4.2 in a Windows Server 2019 environment.

Our MongoDB server logs recently started including a lot of records like this:

[LogicalSessionCacheReap] Failed to reap transaction table: Location13111: wrong type for field (expireAfterSeconds) long != int

Other log records indicated that the problem was with the lsidTTLIndex.

Querying the index information :

db.system.sessions.getIndexes()

returns:

[
  { v: 2, key: { _id: 1 }, name: '_id_', ns: 'config.system.sessions' },
  {
    v: 2,
    key: { lastUse: 1 },
    name: 'lsidTTLIndex',
    ns: 'config.system.sessions',
    expireAfterSeconds: Long('5400')
  }
]

I tried to explicitly change the type to "int" with this command:

db.runCommand (  { collMod: 'system.sessions', index: { name:'lsidTTLIndex', expireAfterSeconds: NumberInt (1800) } } )

and the result was:

{
        "expireAfterSeconds_old" : NumberLong(5400),
        "expireAfterSeconds_new" : 1800,
        "ok" : 1
}

Then runninng db.system.sessions.getIndexes() shows that it's still a Long:

[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_",
                "ns" : "config.system.sessions"
        },
        {
                "v" : 2,
                "key" : {
                        "lastUse" : 1
                },
                "name" : "lsidTTLIndex",
                "ns" : "config.system.sessions",
                "expireAfterSeconds" : NumberLong(1800)
        }
]

Is this warning about the incorrect type likely to cause a problem?

Is there anything I can do go get it to the correct type?

Is dropping the sessions collection safe?

I've seen recommendations to drop the collection, e.g. db.system.sessions.drop()

but I've also seen warnings that developers should not manually change the config db.

Thanks!

Upvotes: 1

Views: 38

Answers (1)

user2333312
user2333312

Reputation: 131

I ran the "db.system.sessions.drop()" command and restarted the server. It rebuilt the collection, and the expireAfterSeconds parameter has the correct type.

So far it seems like dropping the collection solved the problem with on bad side effects.

Upvotes: 0

Related Questions