replicaset not always available in relation

Bug #1459025 reported by Casey Marshall
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
MongoDB Charm
Won't Fix
Low
Mario Splivalo

Bug Description

I've noticed that 'replicaset' is available in the database relation when a replica set has already been explicitly set, and then a relation to mongodb:database is established.

However, I've encountered some problems:

1. The default 'myset' replicaset name is not set on the relation, if I first relate to mongodb:database and then add some units.

2. If I change the replica set name with something like 'juju set mongodb replicaset=foo' after relating to mongodb:database , the relation changed hook does not fire.

I found both of these surprising behaviors. I can work around them by breaking the relation and adding it -- or restricting the order of Juju operations -- so that the mongodb will set the replicaset name on the relation.

However, I am concerned this is fragile behavior.

Are these limitations of Juju, or a defect in the charm that could be improved? My application requires the replicaset name if replication is used with MongoDB (due to driver limitations).

Thanks!
Casey

Casey Marshall (cmars)
description: updated
Revision history for this message
Matthew Williams (mattyw) wrote :

It does appear that the reverse is also true. That a mongodb reporting

> rs.status()
{ "ok" : 0, "errmsg" : "not running with --replSet" }

Can report via the charm a replicaset name

Changed in mongodb (Juju Charms Collection):
assignee: nobody → Mario Splivalo (mariosplivalo)
Revision history for this message
mahmoh (mahmoh) wrote :
Download full text (9.2 KiB)

I've also hit this with an Autopilot deployment on arm64:

mongodb/1 error idle 1.24.6 0/lxc/5 27017/tcp,27019/tcp,27021/tcp,28017/tcp 172.16.9.144 hook failed: "replica-set-relation-changed"

...
2015-10-25 04:52:20 INFO start mongodb start/running, process 3339
2015-10-25 04:52:21 INFO juju-log port_check: Unable to connect to 172.16.9.131:27017/TCP.
2015-10-25 04:52:21 INFO juju-log port_check: Exception: [Errno 111] Connection refused
2015-10-25 04:52:21 INFO juju-log restart_mongod: Waiting for MongoDB to be ready (0/5)
2015-10-25 04:52:31 INFO start mongodb start/running, process 3339
2015-10-25 04:52:31 INFO juju-log port_check: 172.16.9.131:27017/TCP is open
2015-10-25 04:52:31 INFO start mongodb start/running, process 3339
2015-10-25 04:52:32 INFO juju-log port_check: 172.16.9.131:27017/TCP is open
2015-10-25 04:52:32 INFO juju-log start_hook returns: True
2015-10-25 04:58:24 INFO juju-log replica-set:8: replica_set_relation_joined-start
2015-10-25 04:58:25 INFO juju-log replica-set:8: my_hostname: 172.16.9.131
2015-10-25 04:58:25 INFO juju-log replica-set:8: my_port: 27017
2015-10-25 04:58:25 INFO juju-log replica-set:8: my_replset: myset
2015-10-25 04:58:26 INFO juju-log replica-set:8: my_install_order: 0
2015-10-25 04:58:26 INFO juju-log replica-set:8: enable_replset: trying to get lock on: /etc/init/mongodb.conf
2015-10-25 04:58:26 DEBUG juju-log replica-set:8: enable_replset: lock acquired
2015-10-25 04:58:26 DEBUG juju-log replica-set:8: enable_replset: --replset not preset, enabling
2015-10-25 04:58:27 INFO juju-log replica-set:8: regex_sub
2015-10-25 04:58:27 DEBUG juju-log replica-set:8: update_file: /etc/init/mongodb.conf
2015-10-25 04:58:27 DEBUG juju-log replica-set:8: enable_replset will return: True
2015-10-25 04:58:27 DEBUG juju-log replica-set:8: Restarting mongodb after config change (enable replset)
2015-10-25 04:58:28 INFO replica-set-relation-joined mongodb stop/waiting
2015-10-25 04:58:28 INFO replica-set-relation-joined mongodb start/running, process 3566
2015-10-25 04:58:28 INFO replica-set-relation-joined mongodb start/running, process 3566
2015-10-25 04:58:28 INFO juju-log replica-set:8: port_check: Unable to connect to 172.16.9.131:27017/TCP.
2015-10-25 04:58:28 INFO juju-log replica-set:8: port_check: Exception: [Errno 111] Connection refused
2015-10-25 04:58:28 INFO juju-log replica-set:8: restart_mongod: Waiting for MongoDB to be ready (0/5)
2015-10-25 04:58:39 INFO replica-set-relation-joined mongodb start/running, process 3566
2015-10-25 04:58:39 INFO juju-log replica-set:8: port_check: 172.16.9.131:27017/TCP is open
2015-10-25 04:58:39 INFO replica-set-relation-joined mongodb start/running, process 3566
2015-10-25 04:58:39 INFO juju-log replica-set:8: port_check: 172.16.9.131:27017/TCP is open
2015-10-25 04:58:40 INFO juju-log replica-set:8: replica_set_relation_joined-finish
2015-10-25 04:58:43 INFO juju-log replica-set:8: replica_set_relation_changed-start
2015-10-25 04:58:43 DEBUG juju-log replica-set:8: local unit: 172.16.9.131, joining_unit: 172.16.9.144
2015-10-25 04:58:44 INFO juju-log replica-set:8: Initializing replicaset
2015-10-25 04:58:44 DEBUG juju-log re...

Read more...

affects: mongodb (Juju Charms Collection) → mongodb-charm
Revision history for this message
Mario Splivalo (mariosplivalo) wrote :

Hi, Casey.

Just for clarification:

1. For the 'myset' name, you would like that one set inside relaction, regardless of replicaset being formed or not? The charm does not initialize replicaset is there is only a single unit of mongodb deployed.

2. I'm assuming that the reason of relation-changed hook not firing is because you can not (easily) change the replicaset name once replicaset has been initialized - if one wishes to change the replicaset name system collections need to be updated and mongod stopped.
If I change the replica set name with something like 'juju set mongodb replicaset=foo' after relating to mongodb:database , the relation changed hook does not fire.
What would be, in your opinion, desired behavior here?

Changed in mongodb-charm:
status: New → Incomplete
Changed in charm-mongodb:
importance: Undecided → Low
Eric Chen (eric-chen)
Changed in charm-mongodb:
status: Incomplete → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.