Created 06-11-2026 03:48 AM
We are running a sparkly job that runs queries on cloudera CDP hive cluster. The job sometimes stops before a dbwriteTable function, doing nothing and running indefinitely. The job doesn't always stop in the same point, but always during this trywrite function invocation, not catching any error:
trywrite = function(sc, new_name, df, log_obj, wait_sec = 600, max_wait = 3600)
{
start_time = Sys.time()
while (difftime(Sys.time(), start_time, units = 'secs') <= max_wait) {
print(paste0('Attempt to write table: ', new_name, ' - ', Sys.time()))
# Connection is valid?
if (!DBI::dbIsValid(sc)) {
error(log_obj, paste0('Connection not valid during write table: ', new_name))
stop(paste0('Failed to write table: ', new_name))
}
tryCatch({
print(paste0('Writing table: ', new_name))
result = DBI::dbWriteTable(sc, new_name, df)
print(paste0('Write completed table: ', new_name, ' - ', Sys.time()))
return(result)
}, error = function(e) {
error(log_obj, paste0('Connection not valid during write table: ', new_name, ' - ', Sys.time()))
print(paste0('Error message: ', e$message))
print(paste0('Retrying in', wait_sec, ' seconds: ', Sys.time()))
Sys.sleep(wait_sec)
})
}
stop(paste0('Failed to write table before max time: ', new_name))
}
Created 06-12-2026 08:15 PM
@intersoldi Welcome to the Cloudera Community!
To help you get the best possible solution, I have tagged our Spark experts @vafs @Bharati @jagadeesan who may be able to assist you further.
Please keep us updated on your post, and we hope you find a satisfactory solution to your query.
Regards,
Diana Torres,Created 06-15-2026 11:27 AM
Hello @intersoldi,
Thanks for being part of our community.
This could be an issue related to some threads blocked.
Do you see anything on the YARN application log?
On the Spark Event Log, does it always hang on the same task?
Another thing you can try is to get jstacks and review them to see if they are hanging on any specific point or step, for example, a connection or thread.
Created 06-22-2026 12:05 PM
@intersoldi Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. Thanks.
Regards,
Diana Torres,Created 06-25-2026 03:08 AM
Spark lazily evaluates the workload. The actual execution happens when you write the output, usually. If it gets stuck there that means the workload is not tuned with respect to your infrastructure. Try checking the logs, most likely you need to tune your shuffle partition and/or repartition your data.🙂