Several Beam users reported an intermittent error which happens during unpickling in StockUnpickler.find_class. A similar error happens consistently when user's pipelines have instances of super() in their main module, and use --save_main_session, see: BEAM-6158.
In this case the error happens only sometimes, and super() calls don't play a role.
So far I've seen reports of the error on Python 3.5, 3.6, and 3.7.1, on Flink and Dataflow runners. On Dataflow runner so far I have seen this in streaming pipelines only, which use portable SDK worker.
Typical stack trace:
According to Guenther from :
This looks exactly like a race condition that we've encountered on Python
3.7.1: There's a bug in some older 3.7.x releases that breaks the
thread-safety of the unpickler, as concurrent unpickle threads can access a
module before it has been fully imported. See
https://bugs.python.org/issue34572 for more information.
The traceback shows a Python 3.6 venv so this could be a different issue
(the unpickle bug was introduced in version 3.7). If it's the same bug then
upgrading to Python 3.7.3 or higher should fix that issue. One potential
workaround is to ensure that all of the modules get imported during the
initialization of the sdk_worker, as this bug only affects imports done by
Opening this for visibility. Current open questions are:
1. Find a minimal example to reproduce this issue.
2. Figure out whether users are still affected by this issue on Python 3.7.3.
3. Communicate a workarounds for 3.5, 3.6 users affected by this.