Skip to content
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

[Bug]: Python Beam does not fail a job if the main session was present could not be unpickled #25401

Closed
2 of 15 tasks
psobot opened this issue Feb 9, 2023 · 3 comments
Closed
2 of 15 tasks
Labels
bug dataflow done & done Issue has been reviewed after it was closed for verification, followups, etc. P2 python

Comments

@psobot
Copy link
Contributor

psobot commented Feb 9, 2023

What happened?

When launching a Beam pipeline in Python, the --save_main_session flag can be used to serialize the local session's state and load it on the workers. However, if the deserialization of this main session fails, a log line indicating "Could not load main session" is printed, but the pipeline continues to execute - just without its global state, causing NameErrors in various places.

These NameError exceptions don't hint at the original root cause (which is that the main session state failed to deserialize, for whatever reason) which causes a large amount of confusion, especially for those unfamiliar with the intricacies of how Beam works under the hood.

I resolved a similar issue back in Beam 2.31 (#14706) that failed to stop a job if the main session was corrupted; this seems similar.

Expected behaviour: if a main session is present but fails to deserialize, this is considered a "hard error" that stops the entire Beam job from running and forces the programmer to deal with the cause of the failure, rather than proceeding to run the job's code in a half-working state.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Samza Runner
  • Component: Twister2 Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner
@tvalentyn
Copy link
Contributor

Thanks for reporting, sounds like a fixable usability issue. we should probably fail in this case, as long as the main session is provided and not empty. Do you have a repro by chance?

@psobot
Copy link
Contributor Author

psobot commented Feb 21, 2023

I can put together a tiny repro, but in general this can be triggered by:

  • Creating a Python Beam pipeline that's a single script
  • Adding import <any_third_party_module> at the top of the script
  • Not including anything in install_requires in setup.py
  • Launching with --save_main_session

@tvalentyn
Copy link
Contributor

Got it, I don't think we need a repro, reproduction steps are clear. We can improve the logic

'Could not load main session: %s', exception_details, exc_info=True)
and fail with an actionable error. I'll send a PR.

@github-actions github-actions bot added this to the 2.47.0 Release milestone Mar 7, 2023
@damccorm damccorm added the done & done Issue has been reviewed after it was closed for verification, followups, etc. label Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dataflow done & done Issue has been reviewed after it was closed for verification, followups, etc. P2 python
Projects
None yet
Development

No branches or pull requests

3 participants