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

Cache: Coherence #13137

Merged
merged 1 commit into from Jul 7, 2021
Merged

Cache: Coherence #13137

merged 1 commit into from Jul 7, 2021

Conversation

SimonRichardson
Copy link
Member

@SimonRichardson SimonRichardson commented Jul 6, 2021

The cache would fail to notify if you changed from a value and back to
the original value (flip flopping). This is because the underlying hash value
was never written.

This has two consequences:

  1. The cache could never emit a change of the original value
  2. Because we never cached the new value, if the new value was the same
    as the old one, we would still emit the event.

The fix is easy, just save the hash after the notify and we can have
better cache coherency.

QA steps

If you change the model-config logging-config to a new value and back to the
old value, it should now correctly go back to the old value. Flip-flopping of values
in the logging-config exposes this relatively easily.

$ juju bootstrap lxd test
$ juju model-config logging-config="<root>=WARN"
$ juju model-config logging-config="<root>=DEBUG"

View $ juju debug-log -m controller to ensure that the flip-flop happens.

The cache would fail to notify if you changed from a value and back to
the original value. This is because the underlying hash value was never
written. This has two consequences:

 1. The cache could never emit a change of the original value
 2. Because we never cached the new value, if the new value was the same
 as the old one, we would still emit the event.

The fix is easy, just save the hash after the notify and we can have
better cache coherency.
@SimonRichardson SimonRichardson changed the title Cache: Cache coherence Cache: Coherence Jul 6, 2021
@@ -156,6 +156,7 @@ func (w *ConfigWatcher) configChanged(topic string, value interface{}) {
return
}
w.notify()
w.hash = hash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you play around with whether this should happen before or after the notify? (I think after is correct, but I wanted to make sure we thought about it.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I did, but the conclusion I came to was the same.

@@ -156,6 +156,7 @@ func (w *ConfigWatcher) configChanged(topic string, value interface{}) {
return
}
w.notify()
w.hash = hash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you play around with whether this should happen before or after the notify? (I think after is correct, but I wanted to make sure we thought about it.)

@SimonRichardson
Copy link
Member Author

$$merge$$

@jujubot jujubot merged commit 2ecb859 into juju:2.8 Jul 7, 2021
@SimonRichardson SimonRichardson deleted the cache-coherence branch July 7, 2021 10:07
@SimonRichardson SimonRichardson mentioned this pull request Jul 8, 2021
jujubot added a commit that referenced this pull request Jul 8, 2021
#13142

Merge forward 2.8 into 2.9

2ecb859 (upstream/2.8, origin/2.8, 2.8) Merge pull request #13137 from SimonRichardson/cache-coherence
c973d15 (achilleasa/2.8) Merge pull request #13108 from achilleasa/2.8-support-ssh-with-proxy-to-fan-subnets
f505b12 Merge pull request #13097 from achilleasa/2.8-logsink-error-if-persisting-logs-to-db-fails

Conflicts:

CONFLICT (content): Merge conflict in cmd/juju/commands/ssh_unix_test.go
CONFLICT (content): Merge conflict in cmd/juju/commands/ssh_machine.go
CONFLICT (content): Merge conflict in cmd/juju/commands/ssh.go
CONFLICT (content): Merge conflict in cmd/juju/commands/scp.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants