Closed GabrielJones646 closed 8 years ago
Hello @GabrielJones646,
please help us reproducing this issue:
1) what storage engine are you using? Specifically are you using the WiredTiger storage engine?
I just figured out in the mongodb documentation about db.listCollections() that
For MongoDB 3.0 deployments using the WiredTiger storage engine, if you run db.getCollectionNames() from a version of the mongo shell before 3.0 or a version of the driver prior to 3.0 compatible version, db.getCollectionNames() will return no data, even if there are existing collections.
2) what is the output of the following command from the mongoshell?
> use <db_with_issue>
switched to db <db_with_issue>
> db.getCollectionNames()
3) How did you create that db? With restheart (PUT /<db_with_issue>
) or from a different client (e.g. the mongoshell)? In the latter case, how did you create it (for instance, creating a user or inserting some data in a collection)?
4) Are you running mongodb with authentication enabled (--auth option)?
5) Does this error happen also using mongodb 3.2.0, 3.0.8, or 2.6.11?
@GabrielJones646
I just update 1.1.3-SNAPSHOT with the new latest version of the mongo-java-driver (3.2.0).
Note the exception is actually thrown in mongodb java driver code.
Can you try again with latest version?
Thanks
I updated to the latest snapshot. Looks like I still get the same exception.
1) WiredTiger explicitly in the config
2)
foo:PRIMARY> use foo
switched to db foo
foo:PRIMARY> db.getCollectionNames()
[
"migration_log",
"raw_events",
"raw_events_irr_test",
"system.js",
"system.users"
]
3) DB and collections were created via the java driver v2.11.2 via casbah v2.6.2 on mongodb v2.4.6 The DB and collections were migrated from mongd 2.4.6 to 2.6.10 then to 3.0.7. Then they were converted to WiredTiger via replica set resync.
4) We are not using the --auth option, but we do have users and roles configured.
5) I am not sure I want to go through the effort of upgrading and downgrading to test this.
11:57:02.930 [XNIO-1 task-4] ERROR org.restheart.handlers.ErrorHandler - Error handling the request
com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2203) ~[guava-18.0.jar:na]
at com.google.common.cache.LocalCache.get(LocalCache.java:3937) ~[guava-18.0.jar:na]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941) ~[guava-18.0.jar:na]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824) ~[guava-18.0.jar:na]
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4830) ~[guava-18.0.jar:na]
at org.restheart.cache.impl.GuavaLoadingCache.getLoading(GuavaLoadingCache.java:64) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.handlers.injectors.LocalCachesSingleton.getDBProps(LocalCachesSingleton.java:123) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.handlers.injectors.DbPropsInjectorHandler.handleRequest(DbPropsInjectorHandler.java:69) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.security.handlers.SecurityHandler.handleRequest(SecurityHandler.java:50) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.security.handlers.SecurityHandlerDispacher.handleRequest(SecurityHandlerDispacher.java:60) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.handlers.injectors.BodyInjectorHandler.handleRequest(BodyInjectorHandler.java:89) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.handlers.OptionsHandler.handleRequest(OptionsHandler.java:58) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.handlers.injectors.RequestContextInjectorHandler.handleRequest(RequestContextInjectorHandler.java:319) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.security.handlers.CORSHandler.handleRequest(CORSHandler.java:88) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.handlers.PipedHttpHandler.handleRequest(PipedHttpHandler.java:86) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:94) ~[undertow-core-1.3.7.Final.jar:1.3.7.Final]
at io.undertow.server.handlers.HttpContinueAcceptingHandler.handleRequest(HttpContinueAcceptingHandler.java:78) ~[undertow-core-1.3.7.Final.jar:1.3.7.Final]
at org.restheart.handlers.ErrorHandler.handleRequest(ErrorHandler.java:51) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at io.undertow.server.handlers.encoding.EncodingHandler.handleRequest(EncodingHandler.java:72) [undertow-core-1.3.7.Final.jar:1.3.7.Final]
at org.restheart.handlers.GzipEncodingHandler.handleRequest(GzipEncodingHandler.java:65) [restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) [undertow-core-1.3.7.Final.jar:1.3.7.Final]
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793) [undertow-core-1.3.7.Final.jar:1.3.7.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[na:1.8.0_66]
at java.util.ArrayList.get(ArrayList.java:429) ~[na:1.8.0_66]
at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:117) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:173) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:215) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:206) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:112) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.ListCollectionsOperation$1.call(ListCollectionsOperation.java:177) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.ListCollectionsOperation$1.call(ListCollectionsOperation.java:172) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:239) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:212) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.ListCollectionsOperation.execute(ListCollectionsOperation.java:172) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.operation.ListCollectionsOperation.execute(ListCollectionsOperation.java:80) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.Mongo.execute(Mongo.java:773) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.Mongo$2.execute(Mongo.java:760) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.OperationIterable.iterator(OperationIterable.java:47) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.ListCollectionsIterableImpl.iterator(ListCollectionsIterableImpl.java:76) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.MappingIterable.iterator(MappingIterable.java:36) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.MappingIterable.first(MappingIterable.java:41) ~[mongo-java-driver-3.2.0.jar:na]
at org.restheart.db.DbsDAO.doesDbExist(DbsDAO.java:90) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.db.DbsDAO.getDatabaseProperties(DbsDAO.java:139) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.handlers.injectors.LocalCachesSingleton.lambda$setup$37(LocalCachesSingleton.java:73) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.cache.impl.GuavaLoadingCache$1.load(GuavaLoadingCache.java:52) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at org.restheart.cache.impl.GuavaLoadingCache$1.load(GuavaLoadingCache.java:49) ~[restheart-1.1.3-SNAPSHOT.jar:1.1.3-SNAPSHOT]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527) ~[guava-18.0.jar:na]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319) ~[guava-18.0.jar:na]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282) ~[guava-18.0.jar:na]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197) ~[guava-18.0.jar:na]
... 24 common frames omitted
On a related note my browser requesting favicon.ico is causes this exception as well.
These might be two different issues. My missing collection is a separate issue from favicon.ico causing the IndexOutOfBoundsException
Confirmed as of the latest snapshot only /favicon.ico causes the IndexOutOfBoundsException
This is weird. Do you actually have a favicon.ico in place? Could you please post here your yaml configurations (restheart.yml and security.yml)?
I actually noticed this same stack trace with the favicon.ico request as well. Apparently, Restheart thinks favicon.ico is a database (probably because of the URL /favicon.ico
most browsers assume.
There is no favicon.ico in place. I just now added a mongo-mounts section as a workaround:
mongo-mounts:
- what: "*"
where: /data
This resolves the favicon.ico issue; it now returns 404 on the /favicon.ico request
I suppose you could intercept the favicon.ico request and serve the restheart logo. Do you suppose there is anyone out there that has a mongodb named "favicon.ico"?
The 404 would be the correct response in this situation. We often serve static assets with nginx acting as a reverse proxy, so we didn't spot this behavior before. I can try by removing the favicon.ico from a sample project we have here to see if we get that exception.
It appears restheart does not like dots in the db name I just tried /data/foo.bar That should reproduce for you.
I need to check this later with my colleague. Actually, we have a special case where we use the dot when creating file buckets, so far sounds like you are right about restheart not liking the dots. We'll have a look and let you know asap.
rs:PRIMARY> db.getSiblingDB("foo.bar")
2015-12-21T13:22:46.514-0500 E QUERY Error: [foo.bar] is not a valid database name
at Mongo.getDB (src/mongo/shell/mongo.js:41:12)
at DB.getSiblingDB (src/mongo/shell/db.js:20:28)
at (shell):1:4 at src/mongo/shell/mongo.js:41
rs:PRIMARY> db.getSiblingDB("foobar")
foobar
rs:PRIMARY> use foobar
switched to db foobar
rs:PRIMARY> use foo.bar
2015-12-21T13:25:21.194-0500 E QUERY Error: [foo.bar] is not a valid database name
at Mongo.getDB (src/mongo/shell/mongo.js:41:12)
at shellHelper.use (src/mongo/shell/utils.js:537:24)
at shellHelper (src/mongo/shell/utils.js:524:36)
at (shellhelp2):1:1 at src/mongo/shell/mongo.js:41
"For MongoDB deployments running on Unix and Linux systems, MongoDB will not permit database names that include any of the following characters:"
/\. "$
Ok, I didn't remember about that :) My previous comment was misleading, as we have dots but with collection names (say mybucket.files) not databases
BTW, do you have a "static-resources-mounts" part in place in your configuration? I suspect restheart was interpreting the /favicon.ico as a database because you might miss that part. For example:
static-resources-mounts:
- what: browser
where: /browser
welcome-file: browser.html
secured: false
embedded: true
- what: /opt/dist/
where: /
welcome-file: index.html
secured: false
embedded: false
Yes the following chars are not valid data base names: / \ . " $
I will check the request to have a valid database name, in case will return "not acceptable".
Also existing databases with those chars will be filtered out (they should not exist but just in case)
FYI: I tried from the mongo shell to use a database with the dot char in the name and it does not like it
mongodb 3.2.0
> use test.test
2015-12-21T21:31:49.277+0100 E QUERY [thread1] Error: [test.test] is not a valid database name :
Mongo.prototype.getDB@src/mongo/shell/mongo.js:47:12
shellHelper.use@src/mongo/shell/utils.js:606:10
shellHelper@src/mongo/shell/utils.js:593:15
@(shellhelp2):1:1
mongodb 3.0.7
> use test.test
2015-12-21T21:28:40.737+0100 E QUERY Error: [test.test] is not a valid database name
at Mongo.getDB (src/mongo/shell/mongo.js:41:12)
at shellHelper.use (src/mongo/shell/utils.js:537:24)
at shellHelper (src/mongo/shell/utils.js:524:36)
at (shellhelp2):1:1 at src/mongo/shell/mongo.js:41
mongodb 2.6.11
> use test.test
2015-12-21T21:30:31.976+0100 Error: [test.test] is not a valid database name at src/mongo/shell/mongo.js:41
@GabrielJones646 @mkjsix
I just update 1.1.3-SNAPSHOT
the request URI is now checked to refer to a db (and eventually collection) valid mongodb name
example response:
$ http -a a:a 127.0.0.1:8080/db.test/coll
HTTP/1.1 400 Bad Request
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 183
Content-Type: application/hal+json
Date: Mon, 21 Dec 2015 21:52:51 GMT
X-Powered-By: restheart.org
{
"_links": {
"self": {
"href": "/db.test/coll"
}
},
"http status code": 400,
"http status description": "Bad Request",
"message": "illegal database name, see https://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions"
}
that works thanks
MongoDB 3.0.7 restheart 1.1.3-SNAPSHOT
It is also saying the collection does not exist even though I see it on the db page.