Skip to content

check_balancer_running method never returns True on 3.4 #136

@acheccuc

Description

@acheccuc

We have a small MongoDB 3.4 sharded cluster where we have been testing MongoDB Consistent Backup.
After configuring the YML conf file we have been able to start the operation, but we only got this repeated message before a time-out kicked in:

[2017-05-12 13:59:44,684] [INFO] [MainProcess] [Sharding:stop_balancer:113] Balancer is still running, sleeping for 3 sec(s)

Having a look into the code, it seems like check_balancer_running() never returns True because config.locks.state is always 2 in 3.4, the MongoDB documentation reports:

Changed in version 3.4: As of version 3.4, the state field will always have a value 2 to prevent any legacy mongos instances from performing the balancing operation. The when field specifies the time when the config server member became the primary.

While check_balancer_running() looks for 0 to ensure that the balancer is disabled.

def check_balancer_running(self):
        try:
            config = self.connection['config']
            lock   = config['locks'].find_one({'_id': 'balancer'})
            if 'state' in lock and int(lock['state']) == 0:
                return False
            return True
        except Exception, e:
raise DBOperationError(e)

Could you please have a look?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions