Error setting TTL index on collection : sessions <Error: no open connections>

702 views
Skip to first unread message

Smita Saxena

unread,
Jul 9, 2014, 4:00:40 PM7/9/14
to mongod...@googlegroups.com
We're having issues resolving the following bug(s):

----
mongo shell version: 2.4.9
express version: 3.4.0
mongoose version: 3.6.20
connect-mongo version: 0.3.3

Server Status: 

db.serverStatus()
{
"host" : "spoton.it:27272",
"version" : "2.4.9",
"process" : "mongos",
"pid" : 3847,
"uptime" : 10487268,
"uptimeMillis" : NumberLong("10487267638"),
"uptimeEstimate" : 10305015,
"localTime" : ISODate("2014-07-09T19:33:21.095Z"),
"asserts" : {
"regular" : 0,
"warning" : 21,
"msg" : 0,
"user" : 1288,
"rollovers" : 0
},
"connections" : {
"current" : 196,
"available" : 623,
"totalCreated" : NumberLong(182504)
},
"extra_info" : {
"note" : "fields vary by platform",
"heap_usage_bytes" : 9842672,
"page_faults" : 1404780
},
"network" : {
"bytesIn" : 78197575787,
"bytesOut" : 935470208425,
"numRequests" : 322577384
},
"opcounters" : {
"insert" : 425369,
"query" : 157439265,
"update" : 81343942,
"delete" : 2520,
"getmore" : 431649,
"command" : 82584808
},
"mem" : {
"bits" : 64,
"resident" : 79,
"virtual" : 572,
"supported" : true
},
"metrics" : {
"getLastError" : {
"wtime" : {
"num" : 0,
"totalMillis" : 0
}
}
},
"ok" : 1
}

---

ERRORS:

1. Error: Error setting TTL index on collection : sessions <Error: no open connections>
1
at <unknown> (/srv/apps/api/node_modules/connect-mongo/lib/connect-mongo.js line 139 col 23)
throw new Error('Error setting TTL index on collection : ' + self.db_collection_name + ' <' + err + '>');
2
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1227 col 28)
if(err != null) return callback(err, null);
3
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1371 col 30)
if(err != null) return callback(err, null);
4
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 156 col 22)
if(err) return callback(utils.toError(err), null);
5
at commandHandler (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 608 col 48)
if(err != null && result == null) return callback(utils.toError(err), null);
6
at Db._executeQueryCommand (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1705 col 12)
return callback(new Error("no open connections"), null);
7
at Cursor.nextObject (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 649 col 13)
self.db._executeQueryCommand(cmd, {exhaust: self.exhaust, raw:self.raw, read:self.read, connection:self.connection}, commandHandler);
8
at Cursor.toArray (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 155 col 10)
self.nextObject({noReturn: true}, function(err, result) {
9
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1370 col 65)
collection.find(selector).setReadPreference(readPreference).toArray(function(err, indexes) {
10
at Db.collection (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 484 col 44)
return callback == null ? collection : callback(null, collection);

2. 
Error: Error setting TTL index on collection : sessions <MongoError: not authorized for query on calendar.system.indexes>
1
at <unknown> (/srv/apps/api/node_modules/connect-mongo/lib/connect-mongo.js line 139 col 23)
throw new Error('Error setting TTL index on collection : ' + self.db_collection_name + ' <' + err + '>');
2
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1227 col 28)
if(err != null) return callback(err, null);
3
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1371 col 30)
if(err != null) return callback(err, null);
4
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 156 col 22)
if(err) return callback(utils.toError(err), null);
5
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 611 col 39)
return self.close(function() {callback(utils.toError(result.documents[0]['$err']), null);});
6
at Cursor.close (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 939 col 5)
callback(null, self);
7
at commandHandler (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 611 col 21)
return self.close(function() {callback(utils.toError(result.documents[0]['$err']), null);});
8
at null.<anonymous> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1709 col 18)
if(callback) callback(err, result, conn);
9
at g (events.js line 175 col 14)
10
at EventEmitter.emit (events.js line 106 col 17)

William Berkeley

unread,
Jul 9, 2014, 4:28:53 PM7/9/14
to mongod...@googlegroups.com
Hi Smita. The first problem should be solved by setting {auto_reconnect : true} for your express sessions store. The second problem is caused by either 1) failing to initialize the sessions store or 2) providing bad credentials the the MongoDB database. For reference, the set up of the sessions store should look like

var express = require('express');
var MongoStore = require('connect-mongo')(express);
app.use(express.session({
 secret: settings.cookie_secret,
 store: new MongoStore({
   "db": "dbName",
   "host": "localhost",
   "port": "27017",
   "collection": "mysessions",
   "clear_interval": 3600,
   "auto_reconnect": true
 })
}));

Others have experienced #2 when, for example, mixing up dev and prod credentials in their connection strings. Please let me know if this helps or if you need further assistance.

-Will
Message has been deleted

Smita Saxena

unread,
Jul 10, 2014, 1:24:17 PM7/10/14
to mongod...@googlegroups.com
Hi William,

We resolved the first issue but the second still remains:

Error: Error setting TTL index on collection : sessions <MongoError: not authorized for query on calendar.system.indexes>
1
at <unknown> (/srv/apps/api/node_modules/connect-mongo/lib/connect-mongo.js line 139 col 23)
throw new Error('Error setting TTL index on collection : ' + self.db_collection_name + ' <' + err + '>');
2
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1227 col 28)
if(err != null) return callback(err, null);
3
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js line 1371 col 30)
if(err != null) return callback(err, null);
4
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 156 col 22)
if(err) return callback(utils.toError(err), null);
5
at <unknown> (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 611 col 39)
return self.close(function() {callback(utils.toError(result.documents[0]['$err']), null);});
6
at Cursor.close (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 939 col 5)
callback(null, self);
7
at commandHandler (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js line 611 col 21)
return self.close(function() {callback(utils.toError(result.documents[0]['$err']), null);});
8
at g (events.js line 175 col 14)
9
at EventEmitter.emit (events.js line 106 col 17)
10
at Server.Base._callHandler (/srv/apps/api/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/base.js line 130 col 25)
this._callBackStore.emit(id, err, document, info.connection);


We know this isn't a credentials issue so, what else could be causing this? Also, does setting autoreconnect: true slow down the mongo server?




Asya Kamsky

unread,
Jul 10, 2014, 2:04:25 PM7/10/14
to mongodb-user
Smita:

Are you still getting the error with "no open connections"?   Or just the "not authorized" error now?

Asya



--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/2ab6b2ec-e02f-43fb-aa27-27a28f957674%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Asya Kamsky

unread,
Jul 10, 2014, 2:07:43 PM7/10/14
to mongodb-user
One thing I noticed from your previous serverStatus output is this:

"connections" : {
"current" : 196,
"available" : 623,
"totalCreated" : NumberLong(182504)

Available seems really low.   You may not have ulimit settings high enough.   Have you gone through the list here and made sure all your OS level settings are optimal?


Smita Saxena

unread,
Jul 10, 2014, 2:44:18 PM7/10/14
to mongod...@googlegroups.com
Hi Asya,

It also seems as though our number of connections isn't high enough to probably warrant that issue. We're also not seeing the open connections error anymore - just that sessions <MongoError: not authorized for query on calendar.system.indexes> 

Any other thoughts?

William Berkeley

unread,
Jul 10, 2014, 3:29:40 PM7/10/14
to mongod...@googlegroups.com
Hey Smita. Just going off the experience of others who had this problem and wrote about it on the internet, I think it might be caused by using a connection before it is ready. Take a look at this SO question and let me know if the steps there help you.

-Will
10
at EventEmitter.emit (events.js line 106 col <span style="color:
...
Reply all
Reply to author
Forward
0 new messages