With Juju 2.9rc2 we are seeing a problem where the db-relation-joined hook is not being run. Logs show these hooks running: install, db-relation-created, leader-settings-changed, db-relation-changed, config-changed, then db-relation-changed again, start, and db-relation-changed for the third time (which fails, due to required initialization from the db-relation-joined hook not being run). The charm is a k8s Operator Framework charm, using ./dispatch for hooks.
2020-11-10 17:21:24 INFO juju.worker.caasoperator runner.go:527 start "discourse/1"
2020-11-10 17:21:24 INFO juju.worker.leadership tracker.go:217 discourse leadership for discourse/1 denied
2020-11-10 17:21:24 INFO juju.agent.tools symlinks.go:20 ensure jujuc symlinks in /var/lib/juju/tools/unit-discourse-1
2020-11-10 17:21:24 INFO juju.worker.uniter uniter.go:305 unit "discourse/1" started
2020-11-10 17:21:24 INFO juju.worker.uniter uniter.go:592 resuming charm install
2020-11-10 17:21:24 INFO juju.worker.uniter.charm bundles.go:79 downloading cs:~discourse-charmers/discourse-k8s-6 from API server
2020-11-10 17:21:24 INFO juju.downloader download.go:111 downloading from cs:~discourse-charmers/discourse-k8s-6
2020-11-10 17:21:24 INFO juju.downloader download.go:94 download complete ("cs:~discourse-charmers/discourse-k8s-6")
2020-11-10 17:21:24 INFO juju.downloader download.go:174 download verified ("cs:~discourse-charmers/discourse-k8s-6")
2020-11-10 17:21:25 INFO juju.worker.uniter uniter.go:323 hooks are retried true
2020-11-10 17:21:25 INFO juju.worker.uniter resolver.go:147 found queued "install" hook
2020-11-10 17:21:25 INFO juju-log Running legacy hooks/install.
2020-11-10 17:21:28 INFO juju.worker.uniter.operation runhook.go:142 ran "install" hook (via hook dispatching script: dispatch)
2020-11-10 17:21:28 INFO juju.worker.uniter.relation statetracker.go:157 joining relation "discourse:db postgresql:db-admin"
2020-11-10 17:21:28 INFO juju.worker.uniter.relation statetracker.go:193 joined relation "discourse:db postgresql:db-admin"
2020-11-10 17:21:29 INFO juju.worker.uniter.operation runhook.go:142 ran "db-relation-created" hook (via hook dispatching script: dispatch)
2020-11-10 17:21:32 INFO juju.worker.uniter.operation runhook.go:142 ran "leader-settings-changed" hook (via hook dispatching script: dispatch)
2020-11-10 17:21:32 INFO juju.worker.caasoperator initializer.go:124 started pod init on "discourse/1"
2020-11-10 17:21:36 INFO juju.worker.uniter.operation runhook.go:142 ran "db-relation-changed" hook (via hook dispatching script: dispatch)
2020-11-10 17:21:39 INFO juju.worker.uniter.operation runhook.go:142 ran "config-changed" hook (via hook dispatching script: dispatch)
2020-11-10 17:21:39 INFO juju.worker.uniter resolver.go:147 found queued "start" hook
2020-11-10 17:21:41 INFO juju.worker.uniter.operation runhook.go:142 ran "db-relation-changed" hook (via hook dispatching script: dispatch)
2020-11-10 17:21:41 INFO juju-log Running legacy hooks/start.
2020-11-10 17:21:43 INFO juju.worker.uniter.operation runhook.go:142 ran "start" hook (via hook dispatching script: dispatch)
2020-11-10 17:21:44 ERROR juju-log db:1: Uncaught exception while in charm code:
Traceback (most recent call last):
File "./src/charm.py", line 273, in <module>
main(DiscourseCharm)
File "/var/lib/juju/agents/unit-discourse-1/charm/venv/ops/main.py", line 401, in main
_emit_charm_event(charm, dispatcher.event_name)
File "/var/lib/juju/agents/unit-discourse-1/charm/venv/ops/main.py", line 140, in _emit_charm_event
event_to_emit.emit(*args, **kwargs)
File "/var/lib/juju/agents/unit-discourse-1/charm/venv/ops/framework.py", line 234, in emit
framework._emit(event)
File "/var/lib/juju/agents/unit-discourse-1/charm/venv/ops/framework.py", line 678, in _emit
self._reemit(event_path)
File "/var/lib/juju/agents/unit-discourse-1/charm/venv/ops/framework.py", line 723, in _reemit
custom_handler(event)
File "/var/lib/juju/agents/unit-discourse-1/charm/venv/pgsql/opslib/pgsql/client.py", line 431, in _on_changed
self._state.rels[relid]["master"] = new_master
File "/var/lib/juju/agents/unit-discourse-1/charm/venv/ops/framework.py", line 979, in __getitem__
return _wrap_stored(self._stored_data, self._under[key])
KeyError: 1
2020-11-10 17:21:45 ERROR juju.worker.uniter.operation runhook.go:136 hook "db-relation-changed" (via hook dispatching script: dispatch) failed: exit status 1
2020-11-10 17:21:45 INFO juju.worker.uniter resolver.go:143 awaiting error resolution for "relation-changed" hook
2020-11-10 17:21:50 INFO juju.worker.uniter resolver.go:143 awaiting error resolution for "relation-changed" hook
Do we think this is a regression in 2.9?
Does it work in 2.8 or 2.9 beta etc?