Repository navigation
[20.0][MIG] bus_alt_connection: Migration to 20.0 - #3807
Open
Expert-Odoo wants to merge 18 commits into
Open
Expert-Odoo wants to merge 18 commits into
Expert-Odoo wants to merge 18 commits into
Conversation
4 of 30 tasks
Expert-Odoo
force-pushed
the
20.0-mig-bus_alt_connection
branch
from
October 25, 2026 06:44
2a371f6 to
b8967d0
Compare
Contributor
|
Hello, I created a PR to fix/update the documentation. Is it possible to include it? #3814 |
Assisted-by: Claude Opus 5
Expert-Odoo
force-pushed
the
20.0-mig-bus_alt_connection
branch
from
November 2, 2026 16:07
b8967d0 to
417291e
Compare
Author
|
Thanks, good catch. Included in the 20.0 branch (CONFIGURE, README and index.html). The code already reads ODOO_IMDISPATCHER_DB_*, so the doc now matches. |
leemannd
approved these changes
Nov 9, 2026
BhaveshHeliconia
approved these changes
Dec 2, 2026
BhaveshHeliconia
left a comment
Contributor
There was a problem hiding this comment.
LGTM!
Just non-blocking suggestion!
Comment on lines
+72
to
+79
| while conn.notifies: | ||
| for channel in orjson.loads(conn.notifies.pop().payload): | ||
| try: | ||
| channels_by_dbname[channel[0]].append(tuplify(channel)) | ||
| except (IndexError, TypeError): | ||
| # Protect against malformed channels. | ||
| _logger.debug( | ||
| "Discarding malformed bus channel %s", channel |
Contributor
There was a problem hiding this comment.
Suggested change
| while conn.notifies: | |
| for channel in orjson.loads(conn.notifies.pop().payload): | |
| try: | |
| channels_by_dbname[channel[0]].append(tuplify(channel)) | |
| except (IndexError, TypeError): | |
| # Protect against malformed channels. | |
| _logger.debug( | |
| "Discarding malformed bus channel %s", channel | |
| while conn.notifies: | |
| payload = conn.notifies.pop().payload | |
| try: | |
| for channel in orjson.loads(payload): | |
| channel = tuplify(channel) | |
| hash(channel) # used as a key of _topic_by_channel | |
| channels_by_dbname[channel[0]].append(channel) | |
| except (ValueError, LookupError, TypeError): | |
| _logger.warning("Bus._listener_loop ignored malformed imbus payload: %r", payload) |
Matches Odoo 20 core so invalid JSON or an unhashable channel gets skipped cleanly instead of dropping and reconnecting the LISTEN connection via _run_with_retry.
Expert-Odoo
force-pushed
the
20.0-mig-bus_alt_connection
branch
from
December 2, 2026 14:32
1814a67 to
99d5e53
Compare
Author
|
Thanks, applied. Aligned with core 20.0: the whole payload parse is now in one try, so a malformed payload is logged and skipped instead of dropping the LISTEN connection. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migration of
bus_alt_connectionfrom 19.0 to 20.0.The bus dispatcher was rewritten in core 20.0, so this module could not be
ported as is: everything it patched has moved or disappeared.
Adaptations to 20.0
models/bus.py— rewritten against the new dispatcherImDispatchno longer exists. The listener now lives in the newodoo.addons.bus.bus_dispatchermodule, asBusDispatcher, a thread with aworker pool, and the method to override is
_listener_loop, notloop.The module now subclasses
BusDispatcher.dispatchis defined inodoo.addons.bus.bus_dispatcherand imported bymodels.ir_websocketandwebsocket, so the three references are replaced, as before.listening cursor through
odoo.sql_db.db_connect(config["db_system"]), whichgoes through the pooler, while this module opens a plain psycopg2 connection
built from
imdispatcher_db_host/imdispatcher_db_port. That differenceis the entire point of the module, since a pooler in transaction mode never
delivers the asynchronous notifications a
LISTENdepends on. The dispatchflow itself (topics, states, queue, workers) is left untouched to core.
finally, which the 19.0 version did not do.Mirroring a core loop is not ideal, and I would gladly take a better
suggestion. I could not find a seam in 20.0 that lets the listening connection
be swapped without reimplementing the loop; if maintainers know one, say so and
I will rework it.
Testing
pre-commit run -a: green.of PostgreSQL, which I could not reproduce. What I did verify, on a live 20.0
instance, is that the replacement dispatcher takes over and that the bus still
works end to end through it:
odoo.addons.bus_alt_connection.models.bus: Bus._listener_loop listen imbus on db postgres (via db:5432)instead of core's line, andBus: starting 1 dispatch workersright after;bus.bus._sendone(user, …)from ashell is received by the client, so
LISTEN→ queue → worker → websocketall still work with the overridden loop.
Someone running PgBouncer would be welcome to confirm the pooler case.
@trobz