Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only have one top level $addToSet #8259

Merged
merged 1 commit into from Jan 5, 2018

Conversation

howbazaar
Copy link
Contributor

Solutions QA were hitting a situation where regularly their enable-ha command wouldn't result in a mongo replicaset being set up.

Debugging lead to the observation that the controller document had
"machineids": ["0"],
and
"votingmachineids":["0", "1", "2"]

The code always expects that "machineids" is a superset of "votingmachineids".

The transaction ops that were created specified the "$addToSet" mongo operator as a key for two different bson.D values. When this transaction is stashed and recovered, this is flattened to a bson.M that just has a single value.

QA steps

juju bootstrap
juju enable-ha

You get a replica-set enabled juju.

Bug reference

https://bugs.launchpad.net/juju/+bug/1720251

@howbazaar
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Jan 5, 2018

Status: merge request accepted. Url: http://ci.jujucharms.com/job/github-merge-juju

@jujubot jujubot merged commit 2a85a35 into juju:2.3 Jan 5, 2018
@howbazaar howbazaar deleted the 2.3-fix-enable-ha-periodic-failure branch January 5, 2018 03:42
@jameinel
Copy link
Member

jameinel commented Jan 5, 2018

This sounds like we should be changing the deserialization code to use a bson.D instead of a bson.M else this will happen elsewhere

jujubot added a commit that referenced this pull request Jan 5, 2018
state: combine $addToSet updates for storage

## Description of change

When adding filesystems and volumes to a machine
document, ensure that only one $addToSet is used.
Otherwise, if the transaction is interrupted, its
updates will be encoded/decoded as a map, and only
one of the $addToSets will be preserved.

See also #8259

## QA steps

None - can't force this one.

## Documentation changes

None.

## Bug reference

None, preemptive strike.
@howbazaar
Copy link
Contributor Author

It isn't the deserialization, but the serialization of a bson.D.

See gopkg.in/mgo.v2/bson/encode.go line 219. It writes the bson.D out as a flattened dict.

Changing this serialization is probably not feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants