- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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.
Possible solutions, quickest first
1. Start a fresh session. This fixes most cases.
- In the notebook, detach and reattach compute, or use Run > Restart Python / Reset session.
- On serverless, reconnect or reset the environment.
- Rerun the setup cells (imports, variables, DataFrame definitions), then the write.
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?