M13 — choose the Messenger buses where the middleware is installed - #279
Open
gplanchat wants to merge 1 commit into
Open
M13 — choose the Messenger buses where the middleware is installed#279gplanchat wants to merge 1 commit into
gplanchat wants to merge 1 commit into
Conversation
`RegisterDurableMiddlewarePass` insérait les middlewares du bundle en tête de **tous** les bus de l'application, sans échappatoire. Le verrou de reprise du backend DBAL prend un verrou par exécution et le middleware de profil mesure : les appliquer au bus de commandes métier, qui ne transporte aucun message durable, c'est du travail et un point de contention que personne n'a demandés. Ce qui n'était pas en cause, et ne bouge pas : être en tête — un verrou doit envelopper ce qui suit, `doctrine_transaction` compris — et passer par une passe, faute de balise `messenger.middleware` chez Symfony, ce que le docbloc de la passe explique déjà. `durable.messenger.buses` nomme les bus à servir. Le défaut reste **tous**, et ne peut pas être plus fin : le bundle ne sait pas vers quel bus l'application route `ResumeWorkflowMessage`, et deviner retirerait le verrou du bus qui porte réellement le travail — une perte de durabilité silencieuse, exactement ce contre quoi ce verrou existe. Aucune application n'est donc touchée sans le demander. Un identifiant qui ne nomme aucun bus déclaré est refusé à la compilation, avec la liste de ceux qui existent. Laisser passer la faute de frappe produirait le silence qu'on cherche à supprimer : la configuration a l'air posée, rien ne s'installe. Les cas vont dans un fichier neuf plutôt que dans `DurableMiddlewareReachesTheBusTest`, que la PR #277 modifie déjà ; le conteneur du test pose `lock.factory` pour que la fusion des deux se passe sans heurt. Suite unit : 1076 tests contre 1073 sur main, mêmes 4 erreurs d'environnement. PHPStan : 2 erreurs, la base de main. Refs: M13 de documentation/audit/ Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The bundle's middleware went in at the head of every Messenger bus in the application, with no way out.
What was not at fault
Two things the pass does that stay, because they are right:
doctrine_transactionincluded — releasing it before the commit would reopen the window it closes.messenger.middlewaretag: nothing callsfindTaggedServiceIds()on it, and a service carrying it would be defined and never installed, silently. The pass's docblock already documented this, and history bears it out — that is exactly what had happened to the resume lock.The defect is the scope, and nothing else.
What it cost
The DBAL resume lock takes a lock per execution, and the profiling middleware measures. Installing them on an application's business command bus — which carries no durable message — is work and a contention point nobody asked for, on a bus whose author does not even know Durable is in the stack.
The fix
The default remains every bus, deliberately: the bundle does not know which bus the application routes
ResumeWorkflowMessageto. Narrowing it on our own initiative would remove the lock from the bus actually carrying the work — a silent loss of durability, precisely what that lock exists to prevent. No application is affected without asking for it.An unknown identifier is refused at compile time, with the list of declared buses:
Letting the typo through would have produced the very silence we are trying to remove: the configuration looks set, nothing gets installed. That is the failing the audit points at everywhere else in this bundle.
Three cases
Coordination with #277
The cases go into a new file rather than into
DurableMiddlewareReachesTheBusTest, which #277 already modifies — no point adding a conflict. And my test's container placeslock.factory, whose check #277 introduces, so that merging the two goes smoothly whatever the order.Verification
mainunitsuitePre-existing and identical errors (
illuminate/cachemissing on this machine).The configuration reference carries the new node, in both languages, with the reason for the default rather than just the syntax.