state: upgrade leases before starting manager #8011

Merged
merged 1 commit into from Nov 2, 2017

Conversation

Projects
None yet
3 participants
Member

axw commented Nov 2, 2017

Description of change

Since the lease managers are started when you
open a State object, they may be in use before
the lease upgrade step runs. This can lead to
errors, since the lease manager will choke upon
seeing the old lease documents.

To work around this, we upgrade the lease docs
just prior to starting the lease manager. When
we extract the lease managers from State, we
can drop this bit of code and rely on the upgrade
step. The upgrade step has been left in place
for this purpose.

QA steps

  1. juju bootstrap (with a juju from before lease changes - 698a34c)
  2. add a bunch of models
  3. juju upgrade-juju -m controller (with juju from this branch)
  4. confirm operational with "juju status"
  5. confirm there are no "corrupt lease document" errors in the log

Documentation changes

None.

Bug reference

Fixes https://bugs.launchpad.net/juju/+bug/1728972

state: upgrade leases before starting manager
Since the lease managers are started when you
open a State object, they may be in use before
the lease upgrade step runs. This can lead to
errors, since the lease manager will choke upon
seeing the old lease documents.

To work around this, we upgrade the lease docs
just prior to starting the lease manager. When
we extract the lease managers from State, we
can drop this bit of code and rely on the upgrade
step. The upgrade step has been left in place
for this purpose.

Fixes https://bugs.launchpad.net/juju/+bug/1728972
Owner

jameinel commented Nov 2, 2017

another option might be to just allow reading docs that might be the old form rather than treating them as "corrupted".

also, we clearly have a bug where corrupted documents cause us to spin and leak file descriptors. we should try to figure out what is leaking so that general restarts don't leak

Member

axw commented Nov 2, 2017

another option might be to just allow reading docs that might be the old form rather than treating them as "corrupted".

I did consider that, but I'd rather keep this package clean, and put the crappy hack (upgrade before start) with the other crappy hacks (start worker from within State).

also, we clearly have a bug where corrupted documents cause us to spin and leak file descriptors. we should try to figure out what is leaking so that general restarts don't leak

Yup, looking into it now.

as mentioned, there may be other ways but this seems ok. I have not done any manual testing of it yet to know if it really does solve the upgrade problem.

- continue
+ err := st.db().Run(func(int) ([]txn.Op, error) {
+ var doc struct {
+ DocID string `bson:"_id"`
@jameinel

jameinel Nov 2, 2017

Owner

why not leave this as an old type instead of being an embedded struct. type oldLeaseDoc or something like that?

@axw

axw Nov 2, 2017

Member

Why have a named type when you don't need one? I just cribbed from another upgrade. Doesn't really matter either way.

Owner

jameinel commented Nov 2, 2017

Member

axw commented Nov 2, 2017

Landing this, will continue investigating the leak separately.

Member

axw commented Nov 2, 2017

$$merge$$

Contributor

jujubot commented Nov 2, 2017

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

Owner

jameinel commented Nov 2, 2017

@jujubot jujubot merged commit 0e139bd into juju:develop Nov 2, 2017

1 check passed

continuous-integration/jenkins/pr-merge This commit looks good
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment