Java exception (this should be impossible)

879 views
Skip to first unread message

Dustin Norlander

unread,
Aug 20, 2010, 2:24:11 PM8/20/10
to mongod...@googlegroups.com
upgraded to mongo2.1 jar and now I get:

WARNING: Caught
Exception in thread "main" java.lang.IllegalStateException: this
should be impossible
at com.mongodb.DBTCPConnector$MyPort.error(DBTCPConnector.java:287)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:197)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:223)
at com.mongodb.DBCursor._check(DBCursor.java:252)
at com.mongodb.DBCursor._hasNext(DBCursor.java:372)
at com.mongodb.DBCursor.hasNext(DBCursor.java:397)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.loadTop(FoursquareDatasetVenue.java:161)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.main(FoursquareDatasetVenue.java:50)


the calling code is very straight forward:

DBCollection col = new FoursquareDatasetVenue(timeframe).dBCollection();
DBObject query = new BasicDBObject();
query.put("dataset_id", DBHelper.objectId(datasetId));
query.put("te", timeframe.toTrendrrEpoch(date));
log.info(query);
DBCursor cur = col.find(query);
cur.skip(start);
cur.batchSize(limit);
cur.limit(limit);
cur.sort(new BasicDBObject("val", -1));
for (DBObject dsv : cur.toArray()) { // <-- ERROR HERE
DBObject dsv = cur.next();
...
}

Scott Hernandez

unread,
Aug 20, 2010, 2:31:22 PM8/20/10
to mongod...@googlegroups.com
Does this happen all the time, or just randomly?


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Eliot Horowitz

unread,
Aug 20, 2010, 2:35:02 PM8/20/10
to mongod...@googlegroups.com
Just pushed some better logging - can you give it a try?

Dustin Norlander

unread,
Aug 20, 2010, 2:39:56 PM8/20/10
to mongod...@googlegroups.com
Happens every time.

Found the issue though, I had been holding a DB object as a member
variable. That's bad form I guess :)

I'll get the latest and try that if it helps catch a bug in the
driver, otherwise the problem is fixed from my side.

Eliot Horowitz

unread,
Aug 20, 2010, 2:45:48 PM8/20/10
to mongod...@googlegroups.com
Holding a DB should be totally ok - so definitely seems like a driver bug.
Would be great if you could try the master and see what happens.

Dustin Norlander

unread,
Aug 20, 2010, 2:54:54 PM8/20/10
to mongod...@googlegroups.com
Hope this helps

SEVERE: MyPort.error called but _last is null called b/c of
java.lang.IllegalArgumentException: response too long: 1684627207
at com.mongodb.Response.<init>(Response.java:39)
at com.mongodb.DBPort.go(DBPort.java:85)
at com.mongodb.DBPort.call(DBPort.java:56)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:223)
at com.mongodb.DBCollection.findOne(DBCollection.java:486)
at com.mongodb.DBCollection.findOne(DBCollection.java:475)
at com.mongodb.DB.command(DB.java:137)
at com.mongodb.DB.getLastError(DB.java:283)
at com.trendrr.shared.db.helpers.DBHelper.checkForError(DBHelper.java:65)
at com.trendrr.shared.db.MongoWrapper.getAuthenticatedDB(MongoWrapper.java:101)
at com.trendrr.shared.db.TrendrrDB.getFoursquareDB(TrendrrDB.java:62)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.<init>(FoursquareDatasetVenue.java:57)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.<init>(FoursquareDatasetVenue.java:64)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.mongodb.DBCallback._create(DBCallback.java:86)
at com.mongodb.DBCallback.create(DBCallback.java:61)
at org.bson.BasicBSONCallback.objectStart(BasicBSONCallback.java:38)
at org.bson.BasicBSONCallback.objectStart(BasicBSONCallback.java:34)
at org.bson.BSONDecoder.decode(BSONDecoder.java:70)
at org.bson.BSONDecoder.decode(BSONDecoder.java:55)
at org.bson.BSONDecoder.decode(BSONDecoder.java:42)
at com.mongodb.Response.<init>(Response.java:63)
at com.mongodb.DBPort.go(DBPort.java:85)
at com.mongodb.DBPort.call(DBPort.java:56)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)


at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:223)
at com.mongodb.DBCursor._check(DBCursor.java:252)
at com.mongodb.DBCursor._hasNext(DBCursor.java:372)

at com.mongodb.DBCursor._fill(DBCursor.java:440)
at com.mongodb.DBCursor.toArray(DBCursor.java:470)
at com.mongodb.DBCursor.toArray(DBCursor.java:459)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.loadTop(FoursquareDatasetVenue.java:170)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.main(FoursquareDatasetVenue.java:52)
Exception in thread "main" java.lang.IllegalArgumentException:
response too long: 1684627207
at com.mongodb.Response.<init>(Response.java:39)
at com.mongodb.DBPort.go(DBPort.java:85)
at com.mongodb.DBPort.call(DBPort.java:56)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:223)
at com.mongodb.DBCollection.findOne(DBCollection.java:486)
at com.mongodb.DBCollection.findOne(DBCollection.java:475)
at com.mongodb.DB.command(DB.java:137)
at com.mongodb.DB.getLastError(DB.java:283)
at com.trendrr.shared.db.helpers.DBHelper.checkForError(DBHelper.java:65)
at com.trendrr.shared.db.MongoWrapper.getAuthenticatedDB(MongoWrapper.java:101)
at com.trendrr.shared.db.TrendrrDB.getFoursquareDB(TrendrrDB.java:62)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.<init>(FoursquareDatasetVenue.java:57)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.<init>(FoursquareDatasetVenue.java:64)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.mongodb.DBCallback._create(DBCallback.java:86)
at com.mongodb.DBCallback.create(DBCallback.java:61)
at org.bson.BasicBSONCallback.objectStart(BasicBSONCallback.java:38)
at org.bson.BasicBSONCallback.objectStart(BasicBSONCallback.java:34)
at org.bson.BSONDecoder.decode(BSONDecoder.java:70)
at org.bson.BSONDecoder.decode(BSONDecoder.java:55)
at org.bson.BSONDecoder.decode(BSONDecoder.java:42)
at com.mongodb.Response.<init>(Response.java:63)
at com.mongodb.DBPort.go(DBPort.java:85)
at com.mongodb.DBPort.call(DBPort.java:56)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)


at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:223)
at com.mongodb.DBCursor._check(DBCursor.java:252)
at com.mongodb.DBCursor._hasNext(DBCursor.java:372)

at com.mongodb.DBCursor._fill(DBCursor.java:440)
at com.mongodb.DBCursor.toArray(DBCursor.java:470)
at com.mongodb.DBCursor.toArray(DBCursor.java:459)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.loadTop(FoursquareDatasetVenue.java:170)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.main(FoursquareDatasetVenue.java:52)

Eliot Horowitz

unread,
Aug 20, 2010, 3:03:42 PM8/20/10
to mongod...@googlegroups.com
Can you tell me a little more about what you're doing?

It looks like this is what is happening:
- do a find
- iterating results
- creating a new object with a custom type
- that creation triggers a getLastError
- which uses the same connection
- which is bad since its in the middle of streaming results.

Eliot Horowitz

unread,
Aug 20, 2010, 3:08:59 PM8/20/10
to mongod...@googlegroups.com
Added some more code to check for that.
Can you try master once again?

Thanks for the help,
-Eliot

Dustin Norlander

unread,
Aug 20, 2010, 3:46:19 PM8/20/10
to mongod...@googlegroups.com
Yeah, now that you mention it, thats exactly what was happening. I
was assigning a DB in the constructor of the model (we have lazy
initialization code wrapping the standard mongo driver, which checks
for errors before returning).

Here is the output from the latest jar:


SEVERE: MyPort.error called but _last is null called b/c of

java.lang.IllegalStateException: DBPort.go called and expecting a
response while processing another response
at com.mongodb.DBPort.go(DBPort.java:73)

at com.mongodb.DBPort.go(DBPort.java:96)


at com.mongodb.DBPort.call(DBPort.java:56)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:223)
at com.mongodb.DBCursor._check(DBCursor.java:252)
at com.mongodb.DBCursor._hasNext(DBCursor.java:372)
at com.mongodb.DBCursor._fill(DBCursor.java:440)
at com.mongodb.DBCursor.toArray(DBCursor.java:470)
at com.mongodb.DBCursor.toArray(DBCursor.java:459)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.loadTop(FoursquareDatasetVenue.java:170)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.main(FoursquareDatasetVenue.java:52)

Exception in thread "main" java.lang.IllegalStateException: DBPort.go
called and expecting a response while processing another response
at com.mongodb.DBPort.go(DBPort.java:73)

at com.mongodb.DBPort.go(DBPort.java:96)


at com.mongodb.DBPort.call(DBPort.java:56)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:223)
at com.mongodb.DBCursor._check(DBCursor.java:252)
at com.mongodb.DBCursor._hasNext(DBCursor.java:372)
at com.mongodb.DBCursor._fill(DBCursor.java:440)
at com.mongodb.DBCursor.toArray(DBCursor.java:470)
at com.mongodb.DBCursor.toArray(DBCursor.java:459)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.loadTop(FoursquareDatasetVenue.java:170)
at com.trendrr.shared.model.foursquare.FoursquareDatasetVenue.main(FoursquareDatasetVenue.java:52)

On Fri, Aug 20, 2010 at 12:08 PM, Eliot Horowitz

jm.n...@gmail.com

unread,
Aug 31, 2010, 2:58:38 PM8/31/10
to mongodb-user
I also get a similar exception on a save with 2.1 and morphia.

I can cause it by restarting mongod whilst my application is running
but after my application has connected to mongo. The first save after
the restart raises the exception, subsequent saves work fine. If I try
the same with a load it works fine straight after a restart.

java.lang.IllegalStateException: this should be impossible
com.mongodb.DBTCPConnector$MyPort.error(DBTCPConnector.java:287)
com.mongodb.DBTCPConnector.say(DBTCPConnector.java:165)
com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:256)
com.mongodb.DBCollection.save(DBCollection.java:556)
com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:638)
com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:685)
com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:679)
com.google.code.morphia.DAO.save(DAO.java:84)

Eliot Horowitz

unread,
Aug 31, 2010, 4:31:15 PM8/31/10
to mongod...@googlegroups.com
Do you have a stack from the first failure?


--

Ben McCann

unread,
May 2, 2013, 6:17:45 PM5/2/13
to mongod...@googlegroups.com
We're getting this quite a bit, which is causing us lots of difficulty in our production environment. I don't have a simple reproduceable test case yet. It's happened for us using both Morphia and MongoJack. We recently migrated from Morphia to MongoJack because we found a memory leak in Morphia and were hoping it would fix this issue for us as well, but I guess it must be in either the Java driver or server since it's happening with both libraries.

java.lang.IllegalArgumentException: response too long: 1684627207
at com.mongodb.Response.<init>(Response.java:47) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBPort.go(DBPort.java:124) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBPort.call(DBPort.java:74) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:286) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:257) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:310) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBCursor._check(DBCursor.java:368) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBCursor._hasNext(DBCursor.java:459) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBCursor._fill(DBCursor.java:518) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at com.mongodb.DBCursor.toArray(DBCursor.java:553) ~[org.mongodb.mongo-java-driver-2.10.1.jar:na]
at org.mongojack.DBCursor.toArray(DBCursor.java:385) ~[org.mongojack.mongojack-2.0.0-RC5.jar:na]
at org.mongojack.DBCursor.toArray(DBCursor.java:372) ~[org.mongojack.mongojack-2.0.0-RC5.jar:na

Ben McCann

unread,
May 2, 2013, 6:59:05 PM5/2/13
to mongod...@googlegroups.com
Btw, I'm using MongoDB 2.4.3.

Here's another thread I found on the issue as well:

Ben McCann

unread,
May 2, 2013, 7:05:47 PM5/2/13
to mongod...@googlegroups.com

Ben McCann

unread,
May 2, 2013, 7:09:47 PM5/2/13
to mongod...@googlegroups.com
"response too long: 1684627207" is the most common error, but I've also seen this with other numbers there in place of the 1684627207. Here's a log file with a bunch of them.
errors.log

Ben McCann

unread,
May 2, 2013, 7:12:26 PM5/2/13
to mongod...@googlegroups.com
I just upgraded to the 2.11.1 driver and it's still happening:

java.lang.IllegalArgumentException: response too long: 419442946
at com.mongodb.Response.<init>(Response.java:47) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBPort.go(DBPort.java:142) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBPort.call(DBPort.java:92) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:244) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:273) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBCursor._check(DBCursor.java:368) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBCursor._hasNext(DBCursor.java:459) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBCursor._fill(DBCursor.java:518) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBCursor.toArray(DBCursor.java:553) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at org.mongojack.DBCursor.toArray(DBCursor.java:385) ~[org.mongojack.mongojack-2.0.0-RC5.jar:na]
at org.mongojack.DBCursor.toArray(DBCursor.java:372) ~[org.mongojack.mongojack-2.0.0-RC5.jar:na]
--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/DgDG_tpMGtc/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
about.me/benmccann

Ben McCann

unread,
May 3, 2013, 2:19:33 AM5/3/13
to mongod...@googlegroups.com
I've noticed some other fun errors in my logs like this one:

java.lang.IllegalStateException: _out shouldn't be null
at com.mongodb.DBPort.go(DBPort.java:128) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBPort.go(DBPort.java:106) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBPort.findOne(DBPort.java:162) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBPort.runCommand(DBPort.java:170) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBPort$NativeAuthenticator.authenticate(DBPort.java:544) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBPort.authenticate(DBPort.java:322) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBPort.checkAuth(DBPort.java:333) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:243) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:273) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBCursor._check(DBCursor.java:368) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBCursor._hasNext(DBCursor.java:459) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBCursor._fill(DBCursor.java:518) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at com.mongodb.DBCursor.toArray(DBCursor.java:553) ~[org.mongodb.mongo-java-driver-2.11.1.jar:na]
at org.mongojack.DBCursor.toArray(DBCursor.java:385) ~[org.mongojack.mongojack-2.0.0-RC5.jar:na]
at org.mongojack.DBCursor.toArray(DBCursor.java:372) ~[org.mongojack.mongojack-2.0.0-RC5.jar:na]

Ben McCann

unread,
May 3, 2013, 5:52:12 AM5/3/13
to mongod...@googlegroups.com
Okay, think I got it figured out. It seems like the bug's not in mongodb or the java driver, but in some other stuff we were using. I fixed a library we were using to make threadsafe calls to MongoDB and it looks much better. We'll see if any more errors pop up in our logs overnight.  In the meantime I submitted a pull request to MongoJack to clarify in their docs which classes are threadsafe and which are not because I think some confusion there was also part of the problem.

Jeff Yemin

unread,
May 3, 2013, 3:19:17 PM5/3/13
to mongod...@googlegroups.com
So essentially your code was accessing the same instance of com.mongo.DBCursor from multiple threads?


Regards,
Jeff




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.

Ben McCann

unread,
May 3, 2013, 3:24:40 PM5/3/13
to mongod...@googlegroups.com
Yep. It wasn't immediately obvious to me that that wasn't allowed. It would be good to add a note in the JavaDoc stating whether the class is meant to be thread-safe or not. If it is meant to be thread-safe then there might be a bug in it. Otherwise I could submit a pull request stating that it is not thread-safe.

Jeff Yemin

unread,
May 3, 2013, 3:39:58 PM5/3/13
to mongod...@googlegroups.com
We have an annotation to indicate that, so I just added it and pushed: https://github.com/mongodb/mongo-java-driver/commit/da03eef35bb5db6a0dcadac2ad7dbcc1a8047772

Thanks for the suggestion.


Jeff

Ben McCann

unread,
May 3, 2013, 3:45:17 PM5/3/13
to mongod...@googlegroups.com
awesome. thanks!  hopefully it'll save others from trouble down the road =)
Reply all
Reply to author
Forward
0 new messages