[VL] Pandas UDFs fail with "Cannot retain a released vector" on partitions with more than one batch

Open
#13,706 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@LuciferYang is already working on this.

Since Nov 21, 2026.

  • #13707 by @LuciferYang — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
22/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
pandas, python, scala, spark

Research direction

The failure is in ColumnarArrowEvalPythonExec.scala, where adjustRefCnt retains vectors that RefCountedArrowColumnVector.java has already released after the first joined batch. Read how the Python runner's reader reuses the Arrow stream root's vectors, then reproduce with a pandas UDF over a 10,000-row Parquet partition. Done means the second batch no longer hits the released-vector error; PR #13707 is already open against this, so check it first.

Written by the indexing model from the issue text.

Description

Since #13280, a scalar pandas UDF that runs in ColumnarArrowEvalPythonExec fails when a partition sends more than one batch to Python, which happens once a partition has more than spark.gluten.sql.columnar.maxBatchSize rows (4096 by default):

java.lang.IllegalStateException: Cannot retain a released vector
	at org.apache.gluten.vectorized.RefCountedArrowColumnVector.retain(RefCountedArrowColumnVector.java:49)
	at org.apache.spark.api.python.ColumnarArrowEvalPythonExec.adjustRefCnt(ColumnarArrowEvalPythonExec.scala:519)

The Python runner's reader returns every output batch over the same RefCountedArrowColumnVectors, which wrap the vectors of the Arrow stream reader's root. Closing the first joined batch releases them, and the second batch then retains a released vector.

It reproduces on v1.8.0-rc1 with the default configuration: a pandas UDF over a single 10,000-row Parquet partition fails.

This issue was written with the assistance of AI (Claude Opus).

Dominant language
Scala
Stars
1.6k
Forks
679
Avg merge
4d 16h
Merged PRs (30d)
84

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/gluten

All issues in apache/gluten

Similar issues

More Scala issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.