Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Java driver stacktraces on ensureIndex
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Robert Kuhar  
View profile  
 More options May 23 2012, 6:40 pm
From: Robert Kuhar <robertku...@gmail.com>
Date: Wed, 23 May 2012 15:40:27 -0700 (PDT)
Local: Wed, May 23 2012 6:40 pm
Subject: Java driver stacktraces on ensureIndex

I am new to mongo and have inherited a codebase and am working to get it up
and working on my dev box.  I am running OS X Snow Leopard and have
installed mongodb using the instructions
from http://www.mongodb.org/display/DOCS/Quickstart+OS+X with the
straight-up curl of the tarball and deploy out from there.

It starts with the following mong.conf
# Only accept local connections (doesn't work with DM MongoSourceImpl)
bind_ip = 127.0.0.1
port = 27017
rest = true
noauth = true

The JavaScript shell works fine as does all the simple tutorials with the
Java driver, but when I try to run my application, the first call to
ensureIndex stacktraces out the wazoo.  The code looks like...
    DB db = mongoDBManager.getDb(mongoDBName);
    DBCollection profiles = db.getCollection(mongoCollectionName);

    // index: {_id, ModelId}
    BasicDBObject index = new BasicDBObject();
    index.put("_id", 1);
    index.put(ProfileFieldName.ModelID.name(), 1);
    profiles.ensureIndex(index);

...the stacktrace looks like...

2012-05-23T15:16:01.231 [ERROR] o.a.t.i.s.T.RegistryStartup DSN: RID: -
Construction of service RegistryStartup failed: Error invoking service
contribution method
htc.cs.service.device.ui.services.DeviceManagementModule.ensureMongoDBSetup (MongoDBManager,
String, String): can't find a master
org.apache.tapestry5.ioc.internal.OperationException: Error invoking
service contribution method
htc.cs.service.device.ui.services.DeviceManagementModule.ensureMongoDBSetup (MongoDBManager,
String, String): can't find a master
at
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(Operat ionTrackerImpl.java:121)
[tapestry-ioc-5.3.1.jar:na]
...
Caused by: com.mongodb.MongoException: can't find a master
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:406)
~[mongo-java-driver-2.6.5.jar:na]
...

If I change the mongo.conf to NOT bind to 127.0.0.1 via bind_ip (I just
comment it out and bounce mongodb), the application starts without issue.
 I'm a dev box...I'm not running a cluster.  Why is my application looking
for one?

What I'm really asking is how do I troubleshoot this issue?  Is the problem
my server configuration or my configuration of the driver?

Thanks in advance for any insights you may give.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eliot Horowitz  
View profile  
 More options May 24 2012, 12:55 am
From: Eliot Horowitz <el...@10gen.com>
Date: Thu, 24 May 2012 00:55:03 -0400
Local: Thurs, May 24 2012 12:55 am
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex
Can you send the code where you create the Mongo object?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Kuhar  
View profile  
 More options May 24 2012, 11:41 am
From: Robert Kuhar <robertku...@gmail.com>
Date: Thu, 24 May 2012 08:41:34 -0700 (PDT)
Local: Thurs, May 24 2012 11:41 am
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex

Sure thing...

    public MongoSourceImpl(
            Collection<ServerAddress> replicaSet,
            @Symbol("mongo.slave-ok") Boolean slaveOk,
            @Symbol("mongo.write-concern-fsync") Boolean fsync,
            @Symbol("mongo.write-concern-w-timeout") Integer wTimeout,
            @Symbol("mongo.write-concern-w") Integer w,
            @Symbol("mongo.connections-per-host") Integer
connectionsPerHost,
            @Symbol("mongo.blocked-threads-per-connection") Integer
blockedThreadsPerConnection,
            @Symbol("mongo.auto-connect-retry") Boolean autoConnectRetry,
            @Symbol("mongo.connect-timeout") Integer connectTimeout,
            @Symbol("mongo.max-wait-time") Integer maxWaitTime,
            @Symbol("mongo.socket-time-out") Integer socketTimeout,
            @Symbol("mongo.socket-keep-alive") Boolean socketKeepAlive
    ) {

        MongoOptions mongoOptions = new MongoOptions();
        mongoOptions.slaveOk = slaveOk;
        mongoOptions.fsync = fsync;
        mongoOptions.wtimeout = wTimeout;
        mongoOptions.w = w;
        mongoOptions.connectionsPerHost = connectionsPerHost;
        mongoOptions.threadsAllowedToBlockForConnectionMultiplier =
blockedThreadsPerConnection;
        mongoOptions.autoConnectRetry = autoConnectRetry;
        mongoOptions.connectTimeout = connectTimeout;
        mongoOptions.maxWaitTime = maxWaitTime;
        mongoOptions.socketTimeout = socketTimeout;
        mongoOptions.socketKeepAlive = socketKeepAlive;

        mongo = new Mongo(new ArrayList<ServerAddress>(replicaSet),
mongoOptions);
    }

...it is the case, on my dev box, that the replicaSet collection is empty
at the time of new Mongo.

Bob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Kuhar  
View profile  
 More options May 24 2012, 12:56 pm
From: Robert Kuhar <robertku...@gmail.com>
Date: Thu, 24 May 2012 09:56:11 -0700 (PDT)
Local: Thurs, May 24 2012 12:56 pm
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex

I lied.  At the time I pass through the MongoSourceImpl constructor, the
Collection<ServerAddress> replicaSet has exactly one member:  

[localhost:27017].  There should be at least 3 members there if I was
actually doing Replication, no?  Please excuse my naivety, I'm new to
Mongo.  I'm just trying to get this codebase to run on a dev box where
there is no replication going on.  I am struggling to figure out which of
the MongoOptions apply to the "dev box" use case and which apply to the
"production" use case (were we do have 3 servers in the cluster).  My
investigation is narrowing in on the MongoOptions as the actual root cause.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Hernandez  
View profile  
 More options May 24 2012, 1:01 pm
From: Scott Hernandez <scotthernan...@gmail.com>
Date: Thu, 24 May 2012 13:01:27 -0400
Local: Thurs, May 24 2012 1:01 pm
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex
If you are not connecting to a replicaset then don't use the
constructor which takes a list (even of 1) -- this is only to be used
when connecting to a replica set.

You could also run your dev instance as a replicaset of one member,
which will make it always the primary/master.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Kuhar  
View profile  
 More options May 24 2012, 3:12 pm
From: Robert Kuhar <robertku...@gmail.com>
Date: Thu, 24 May 2012 12:12:28 -0700 (PDT)
Local: Thurs, May 24 2012 3:12 pm
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex

Thanks for your reply, and I am confident that I now have my dev box
running as worst ever single-node replSet.  Unfortunately I still get the
same stacktrace;
    "com.mongodb.MongoException: can't find a master"
...from the troublesome ensureIndex call...
   collection.ensureIndex(new BasicDBObject("login", 1), "login_index", true
);.

The conclusion I am reaching is that one cannot have mongo configured for
bind_ip = 127.0.0.1 in the presence of replSets.  Is this a bug or just a
total misunderstanding the bind_ip mongo startup parameter on my part?

So many questions, so little time.  Sigh.  For the time being, I am going
to leave my setup as single-node replSet and just comment out the
bind_ip=127.0.0.1 in my mongo.conf.  The effect of this is that my dev box
is now a mongo-slut, accepting connections from anywhere, correct?

In any event, thanks so much for your help.  The ways of MongoDB are become
more clear to me as I work my way through each of these challenges.

Bob

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Hernandez  
View profile  
 More options May 24 2012, 3:14 pm
From: Scott Hernandez <scotthernan...@gmail.com>
Date: Thu, 24 May 2012 15:14:22 -0400
Local: Thurs, May 24 2012 3:14 pm
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex
What does your rs.config() show?

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Kuhar  
View profile  
 More options May 24 2012, 4:40 pm
From: Robert Kuhar <robertku...@gmail.com>
Date: Thu, 24 May 2012 13:40:41 -0700 (PDT)
Local: Thurs, May 24 2012 4:40 pm
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex

bobk-mbp:DM_Server bobk$ mongo
MongoDB shell version: 2.0.4
connecting to: test
PRIMARY> rs.config();
{
"_id" : "dmReplSet",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" : "localhost:27017"

}
]
}

PRIMARY>

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Hernandez  
View profile  
 More options May 24 2012, 4:47 pm
From: Scott Hernandez <scotthernan...@gmail.com>
Date: Thu, 24 May 2012 16:47:25 -0400
Local: Thurs, May 24 2012 4:47 pm
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex
Does localhost resolve to 127.0.0.1? On some machines it does not.

You could change your bind_ip to localhost if they are different on
different systems.

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Kuhar  
View profile  
 More options May 24 2012, 8:05 pm
From: Robert Kuhar <robertku...@gmail.com>
Date: Thu, 24 May 2012 17:05:22 -0700 (PDT)
Local: Thurs, May 24 2012 8:05 pm
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex

That's a great question and the answer is not clear to me.  Localhost is
bound to 127.0.0.1 in my /etc/hosts file and ping manages to resolve it to
127.0.0.1.

Further, if I tail -F the mongo console log I see "connection accepted" and
"end connection" messages for each connection made.  From the JavaScript
shell these messages look like...
    Thu May 24 16:52:53 [initandlisten] connection accepted from
127.0.0.1:27162 #21
    Thu May 24 16:52:56 [conn21] end connection 127.0.0.1:27162
From my initial Mongo Java Tutorial App (new Mongo();) they look like...
    Thu May 24 16:47:54 [initandlisten] connection accepted from
127.0.0.1:27098 #17
    Thu May 24 16:47:57 [conn17] end connection 127.0.0.1:27098
But, from the app that is giving me all the problems (new Mongo(newArrayList<ServerAddress>(replicaSet), mongoOptions);), the log suggests
that the connection(s) are coming from an IP address other than 127.0.0.1
    Thu May 24 16:49:15 [initandlisten] connection accepted from
10.78.4.124:27114 #18
    Thu May 24 16:54:57 [conn18] end connection 10.78.4.124:27114

Given what I see in the mongo log, I don't think trying to
bind_ip=localhost would work either as the driver is forging that
connection as if it is coming in from the outside (as little as I know of
Mongo, my understanding of the network layer is equally shallow).

I think I need to refine my earlier assertion.  The Java Driver, in the
presence of replSets, is incompatible with the mongo server running with
bind_ip = 127.0.0.1.  This feels more like a java driver bug all the time,
but I am also coming to understand that my "Replica Set cluster of 1 on
localhost" is not representative of any production quality deployment.

Bob

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Yemin  
View profile   Translate to Translated (View Original)
 More options May 25 2012, 10:58 am
From: Jeff Yemin <jeff.ye...@10gen.com>
Date: Fri, 25 May 2012 07:58:54 -0700 (PDT)
Local: Fri, May 25 2012 10:58 am
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex

I suspect that you're hitting https://jira.mongodb.org/browse/JAVA-249,
which will be resolved in 2.8.0.  Does it work if you connect like:

new Mongo("127.0.0.1", options)

?

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Kuhar  
View profile  
 More options May 25 2012, 1:48 pm
From: Robert Kuhar <robertku...@gmail.com>
Date: Fri, 25 May 2012 10:48:14 -0700 (PDT)
Local: Fri, May 25 2012 1:48 pm
Subject: Re: [mongodb-user] Java driver stacktraces on ensureIndex

Yes.  mongo = new Mongo( "127.0.0.1", mongoOptions ); works and the mongo
log records it as a connection from 127.0.0.1 like "Fri May 25 10:41:42
[initandlisten] connection accepted from 127.0.0.1:40764 #2"

https://jira.mongodb.org/browse/JAVA-249 does indeed describe my
observation.  It looks like I am eagerly awaiting 2.8.0 drivers.  Thanks.

Bob

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »