-
Notifications
You must be signed in to change notification settings - Fork 491
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
base: main
Are you sure you want to change the base?
Conversation
dac8db6
to
c484ff6
Compare
c484ff6
to
4f2f9a3
Compare
/build |
There was a problem hiding this 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.
if w.config.StatePool == nil { | ||
w.config.Logger.Infof("no state pool, doing nothing") | ||
<-w.catacomb.Dying() | ||
return w.catacomb.ErrDying() | ||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
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. |
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
juju.worker.dualwritehack updated model config in mongo
is in the logs.Documentation changes
Need to add this to the risk registry.
Links
Jira card: JUJU-