Skip to content

[FLINK-39532][python] Fix race condition in Python AsyncScalarFunctionOperation#28036

Open
auroflow wants to merge 1 commit intoapache:masterfrom
auroflow:auroflow/fix-async
Open

[FLINK-39532][python] Fix race condition in Python AsyncScalarFunctionOperation#28036
auroflow wants to merge 1 commit intoapache:masterfrom
auroflow:auroflow/fix-async

Conversation

@auroflow
Copy link
Copy Markdown
Contributor

What is the purpose of the change

Currently in AsyncScalarFunctionOperation, the process_element method submits the input value to an asyncio event loop and returns immediately. For flatten row, the input comes from FlattenRowCoderImpl.decode_from_stream. In the Cython implementation in coder_impl_fast.pyx, this method returns a reused list; by the time the async function runs, this reused list has already been overwritten by the next decoded row. This will make Python async UDFs receive wrong input values, causing corrupted results.

This pull request snapshots input flatten rows in Python AsyncScalarFunctionOperation to avoid race conditions.

Brief change log

  • Snapshots input flatten rows in Python AsyncScalarFunctionOperation to avoid race conditions

Verifying this change

This change is verified by manually running SQL jobs containing Python async UDFs in a production cluster.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (yes)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Opus 4.7

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Apr 26, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@auroflow auroflow force-pushed the auroflow/fix-async branch from 8f3e7ea to 5e926d0 Compare April 28, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants