Sunday
I keep on getting this error message when trying to create a parquet in my notebook. Has anyone found this error too? My overwrite path was working perfectly fine before.
SparkConnectGrpcException: (java.lang.IllegalStateException) operationId: d5871ddd-4b1c-4838-a074-9a42a66e28ee with status ReadyForExecution is not within statuses List(Finished, Failed, Canceled) for event Closed
Wednesday
Hi @inaafina ,
The error comes from Spark Connect, the client-server layer Databricks uses on serverless compute and standard (formerly shared) access mode clusters. It usually means the Spark session that ran your command had expired or been closed before the operation finished. The serverโs cleanup then found the operation stuck in ReadyForExecution and raised this error.
So itโs normally a session or compute problem, not a problem with your Parquet code. That fits with your overwrite path working before.
1. Start a fresh session. This fixes most cases.
2. Check whether the compute restarted or timed out. If the cluster auto-terminated, restarted, or the notebook sat idle for a long time, the old session is gone. Rerun from the top instead of only the last cell.
3. Retry the write. The error can be transient. For scheduled jobs, add a simple retry:
import time
for attempt in range(3):
try:
df.write.mode("overwrite").parquet(target_path)
break
except Exception as e:
if attempt == 2:
raise
print(f"Write failed, retrying: {e}")
time.sleep(30)4. Check that you arenโt reading and overwriting the same path. If df was built by reading from target_path, overwriting that path in the same query deletes the files Spark is still reading. That fails, and on Spark Connect it can surface as a confusing error like this one. Write to a temporary path first, or materialize the data before overwriting.
5. Use a supported location. On serverless and standard access mode, write to a Unity Catalog volume or an external location rather than DBFS root or mount paths:
df.write.mode("overwrite").parquet("/Volumes/<catalog>/<schema>/<volume>/my_output")6. Consider Delta instead of plain Parquet. A Delta overwrite is atomic: readers never see a half-written folder, and a failed write doesnโt leave partial files.
df.write.format("delta").mode("overwrite").saveAsTable("<catalog>.<schema>.my_table")7. Try a newer runtime or different compute. Because itโs a Spark Connect bug, a newer Databricks Runtime or serverless environment version may fix it. As a workaround, run the notebook on a dedicated (single user) access mode cluster, which doesnโt route Python through Spark Connect the same way.
8. If it keeps happening: capture the full stack trace and the operationId from the error, check the driver logs, and raise a Databricks support ticket. The operation ID lets support trace the exact session.
To narrow it down: are you on serverless or a cluster, and which path are you writing to (DBFS, a volume or cloud storage)? Also, is the DataFrame read from the same path youโre overwriting?
Wednesday
Hello @inaafina, I took a look at both internal and external documentation and here is what I found.
This is a Spark Connect lifecycle error, and your Parquet code is probably fine. Spark Connect is the client-server layer notebooks use on serverless and standard access mode compute. The server tried to close an operation it still had marked as ReadyForExecution, which usually means the session expired or was released underneath it. @yasmeen explained that part well.
The signature matches a known Apache Spark bug, SPARK-50176. In that report the overwrite finished and the data was correct, but the client never got its response and the server threw this error during cleanup. It showed up on large, long-running writes, affected Spark 3.5.2, and was fixed in 3.5.4.
Here's what I'd do, in order:
databricks-connect to your runtime version. @Satyasai is right that the client version matters, and @saurabh18cs's databricks environments setup-local command is the easy way to build a matching environment.operationId and driver logs.Two cautions, though. spark.connect.client.session.timeout isn't in the documented Spark configuration, so it may be silently ignored. And @Satyasai's repartition tip won't fix the root cause, though it can shorten a very long write. Longer term, @yasmeen's suggestion to use Delta instead of plain Parquet makes overwrites much safer, since the commit is atomic.
References:
databricks environments CLI reference: https://docs.databricks.com/aws/en/dev-tools/cli/reference/environments-commandsIf you found this answer helpful please check off "Accept as Solutions" so that others can have confidence in the answer.
Regards, Louis.
Sunday
1. Upgrade Databricks Connect and gRPC Packages
If you are using an external IDE to run this workflow using Databricks Connect then you may experience gRPC state race conditions if your client is out of date. Upgrade your local Python packages to the latest versions.
Bash
pip install --upgrade databricks-connect grpcio grpcio-status
Databricks have made several improvements in their clients to improve stability around proxies dropping and sessions throwing exceptions.
2. Optimize or Repartition Large Overwrites
If you are overwriting a large dataset then you may be reaching the timeout or payload limits on the gRPC channel due to the high volume of data being serialised.
You can re-partition your data before overwriting. This will reduce any skew in your partitions or split large datasets into smaller ones.
Python
df.repartition(200).write.mode("overwrite").parquet("path/to/data")
3. Increase Timeout for Spark Connect Client
If you are taking a long time to stage your writes then you may get a timeout on the gRPC channel. You can increase these timeout values using your Spark session configurations.
Python
spark.conf.set("spark.connect.client.session.timeout", "600s")
Monday
Hi @inaafina setup like this , this is a new way to automatically resolve right package versions based on your compute. you have to use databricks cli
e.g. databricks environments setup-local \ --serverless-version 5 \ --dry-run
Wednesday
Hi @inaafina ,
The error comes from Spark Connect, the client-server layer Databricks uses on serverless compute and standard (formerly shared) access mode clusters. It usually means the Spark session that ran your command had expired or been closed before the operation finished. The serverโs cleanup then found the operation stuck in ReadyForExecution and raised this error.
So itโs normally a session or compute problem, not a problem with your Parquet code. That fits with your overwrite path working before.
1. Start a fresh session. This fixes most cases.
2. Check whether the compute restarted or timed out. If the cluster auto-terminated, restarted, or the notebook sat idle for a long time, the old session is gone. Rerun from the top instead of only the last cell.
3. Retry the write. The error can be transient. For scheduled jobs, add a simple retry:
import time
for attempt in range(3):
try:
df.write.mode("overwrite").parquet(target_path)
break
except Exception as e:
if attempt == 2:
raise
print(f"Write failed, retrying: {e}")
time.sleep(30)4. Check that you arenโt reading and overwriting the same path. If df was built by reading from target_path, overwriting that path in the same query deletes the files Spark is still reading. That fails, and on Spark Connect it can surface as a confusing error like this one. Write to a temporary path first, or materialize the data before overwriting.
5. Use a supported location. On serverless and standard access mode, write to a Unity Catalog volume or an external location rather than DBFS root or mount paths:
df.write.mode("overwrite").parquet("/Volumes/<catalog>/<schema>/<volume>/my_output")6. Consider Delta instead of plain Parquet. A Delta overwrite is atomic: readers never see a half-written folder, and a failed write doesnโt leave partial files.
df.write.format("delta").mode("overwrite").saveAsTable("<catalog>.<schema>.my_table")7. Try a newer runtime or different compute. Because itโs a Spark Connect bug, a newer Databricks Runtime or serverless environment version may fix it. As a workaround, run the notebook on a dedicated (single user) access mode cluster, which doesnโt route Python through Spark Connect the same way.
8. If it keeps happening: capture the full stack trace and the operationId from the error, check the driver logs, and raise a Databricks support ticket. The operation ID lets support trace the exact session.
To narrow it down: are you on serverless or a cluster, and which path are you writing to (DBFS, a volume or cloud storage)? Also, is the DataFrame read from the same path youโre overwriting?
Wednesday
Hello @inaafina, I took a look at both internal and external documentation and here is what I found.
This is a Spark Connect lifecycle error, and your Parquet code is probably fine. Spark Connect is the client-server layer notebooks use on serverless and standard access mode compute. The server tried to close an operation it still had marked as ReadyForExecution, which usually means the session expired or was released underneath it. @yasmeen explained that part well.
The signature matches a known Apache Spark bug, SPARK-50176. In that report the overwrite finished and the data was correct, but the client never got its response and the server threw this error during cleanup. It showed up on large, long-running writes, affected Spark 3.5.2, and was fixed in 3.5.4.
Here's what I'd do, in order:
databricks-connect to your runtime version. @Satyasai is right that the client version matters, and @saurabh18cs's databricks environments setup-local command is the easy way to build a matching environment.operationId and driver logs.Two cautions, though. spark.connect.client.session.timeout isn't in the documented Spark configuration, so it may be silently ignored. And @Satyasai's repartition tip won't fix the root cause, though it can shorten a very long write. Longer term, @yasmeen's suggestion to use Delta instead of plain Parquet makes overwrites much safer, since the commit is atomic.
References:
databricks environments CLI reference: https://docs.databricks.com/aws/en/dev-tools/cli/reference/environments-commandsIf you found this answer helpful please check off "Accept as Solutions" so that others can have confidence in the answer.
Regards, Louis.
Wednesday
Hi @inaafina, adding a bit more context on this one, because the error message is confusing.
That message doesn't come from your parquet write itself. It comes from Spark Connect's bookkeeping for each operation. (Serverless notebooks and Databricks Connect both run on Spark Connect.) Every command gets an operation id and moves through states like Started, ReadyForExecution and Finished. Your operation was told to close while it was still at ReadyForExecution, and the server refused that state change. Open-source Spark has had bugs exactly like this (SPARK-46186 and SPARK-50176, both fixed upstream), usually set off by an interrupt, a dropped connection or a session release arriving at the wrong moment. So "it worked before and nothing in my code changed" fits this well.
What I'd try, in order:
display(dbutils.fs.ls("<your output path>"))
spark.read.parquet("<your output path>").count()One small note on the earlier reply: I couldn't find spark.connect.client.session.timeout in the Databricks or Spark docs, so I wouldn't count on that setting.
If it still happens after a fresh session, could you share whether this is serverless or classic compute, what kind of path you're writing to (Volume, DBFS, cloud storage), and roughly how big the data is? If it happens every time on serverless, it's worth a support ticket with the operationId from the error, since they can trace it on the server side.