fix(stream): log supervision Resume/Restart in MapAsync operators#3124
Merged
Conversation
Motivation: MapAsync, MapAsyncUnordered, and MapAsyncPartitioned silently skip failed elements when the supervision strategy returns Resume or Restart, making production debugging difficult. Modification: Add StageLogging mixin and log supervision failures at the configured error level (respecting stage-errors-default-log-level and per-stage LogLevels.onFailure attribute) before skipping elements. Logging is placed in pushNextIfPossible / futureCompleted / onPush sync handler to avoid double-logging via Holder's directive cache. Result: Supervision Resume/Restart decisions now produce log entries with exception details, enabling users to diagnose dropped elements. Tests: - FlowMapAsyncSpec: 3 new log verification tests (async, sync, Off) - FlowMapAsyncUnorderedSpec: 3 new log verification tests - FlowMapAsyncPartitionedSpec: 3 new log verification tests (ordered + unordered + Off) - All 74 existing + new tests pass References: Fixes #3103
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.
Summary
MapAsync,MapAsyncUnordered, andMapAsyncPartitionedstage-errors-default-log-levelconfiguration and per-stageLogLevels.onFailureattribute from Add fine-grained stream error logging control #2805Holder's directive cache to ensure exactly one log per failure)Changes
MapAsync: AddedStageLoggingmixin,logSupervisionFailurehelper, logging inpushNextIfPossibleand sync exception handlerMapAsyncUnordered: AddedStageLoggingmixin,logSupervisionFailurehelper, logging infutureCompletedand sync exception handlerMapAsyncPartitioned: AddedStageLoggingmixin,logSupervisionFailurehelper, logging in both ordered and unorderedpushNextIfPossibleand sync exception handlerMotivation
MapAsync,MapAsyncUnordered, andMapAsyncPartitionedsilently skip failed elements when the supervision strategy returns Resume or Restart. This makes production debugging difficult — users cannot see which elements were dropped or what exceptions occurred.Modification
StageLoggingtrait for all three operatorslogSupervisionFailurehelper that checksLogLevels.onFailureattribute, falls back toLogLevels.defaultErrorLevel(system), and logs at the configured levelMapAsyncandMapAsyncPartitioned, logging is placed inpushNextIfPossible(not infutureCBor the fast path) to avoid double-logging since theHoldercaches the supervision directiveMapAsyncUnordered, logging is placed infutureCompleted(no buffer re-processing)HoldercachingResult
Supervision Resume/Restart decisions now produce log entries with exception details, enabling users to diagnose dropped elements. Log level can be controlled via
pekko.stream.materializer.stage-errors-default-log-levelconfig or per-stageActorAttributes.logLevels.Tests
FlowMapAsyncSpec: 3 new tests (async future failure logs, sync throw logs, log level Off disables logging)FlowMapAsyncUnorderedSpec: 3 new tests (same pattern)FlowMapAsyncPartitionedSpec: 3 new tests (ordered, unordered, log level Off)References
Fixes #3103