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

Add dualwritehack worker that handles model concerns that need dual writing. #17347

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hpidcock
Copy link
Member

@hpidcock hpidcock commented May 7, 2024

This is a hack. A horrible hack. But it allows us to isolate dual writing concerns to a single model worker that has access to both the model servicefactory and state. That can be deleted when the time comes that we have no mongo.

This is an eventually consistent approach to dual writing.

First example is dual writing model config. It watches model config, and smashes the values into state. Simple.

QA steps

  • No unit tests because this should not live long, tests are integration tests.
  • Bootstrap
  • Change model config
  • See that juju.worker.dualwritehack updated model config in mongo is in the logs.
  • Probably something else to test.

Documentation changes

Need to add this to the risk registry.

Links

Jira card: JUJU-

@hpidcock hpidcock added the 4.0 label May 7, 2024
@hpidcock hpidcock force-pushed the modelconfig-dualwrite branch 3 times, most recently from dac8db6 to c484ff6 Compare May 7, 2024 07:32
@hpidcock
Copy link
Member Author

hpidcock commented May 7, 2024

/build

Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

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

I completely understand why we need this, but I want to iterate to everyone following along; this will make everything eventually consistent and by eventually consistent, I mean between calls to the model config. This introduces the similar problems we had when we had the model cache and all the horrid distributed problems that it came with. As pointed out, this could help migrate complex refactorings between dqlite and mongo, with dqlite being the source of truth.

There is one ray of light to this as a concept; we will really see if there are any problems to the changestream. This will definitely exercise the underlying eventsource watchers.

Comment on lines +57 to +61
if w.config.StatePool == nil {
w.config.Logger.Infof("no state pool, doing nothing")
<-w.catacomb.Dying()
return w.catacomb.ErrDying()
}
Copy link
Member

Choose a reason for hiding this comment

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

When would this happen?


// ModelConfigDualWrite is a worker that watches dqlite model config and smashes it into
// mongo state model config.
func (w *DualWriteWorker) ModelConfigDualWrite(stopCh <-chan struct{}) error {
Copy link
Member

Choose a reason for hiding this comment

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

OT: I really wish the simple worker passed in a context that was scoped to the tomb. I'll propose a PR to fix this.

@SimonRichardson
Copy link
Member

There are places where we're not writing all the config to dqlite. Considering fan-config is only written to mongo currently, so we need to fix that before this can land.

@hpidcock hpidcock added the do not merge Even if a PR has been approved, do not merge the PR! label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.0 do not merge Even if a PR has been approved, do not merge the PR!
Projects
None yet
2 participants