Spark: preload delete files to avoid deadlocks#15712
Spark: preload delete files to avoid deadlocks#15712kinolaev wants to merge 1 commit intoapache:mainfrom
Conversation
Signed-off-by: Sergei Nikolaev <kinolaev@gmail.com>
|
@kinolaev is this an issue you see in practice or just if you reduce the connection pool size? Typically, there would only be one data file processed by a task, so as long as there's at least two connections available, I would think that the delete operation would be able to process the data file (the task being operated on) and at least one delete at a time. I believe the default connection pool size is 50, so why would this be an issue in practice? |
|
I see the issue in practice. I guess data files are loaded in parallel and at least in case of S3FileIO the connection pool is shared. I'm sure that two connections are not enough. I've just added two more inserts and deletes create table sparkdeletefilter(id bigint)
tblproperties('write.delete.mode'='merge-on-read');
insert into sparkdeletefilter select id from range(0, 2);
insert into sparkdeletefilter select id from range(2, 4);
insert into sparkdeletefilter select id from range(4, 6);
delete from sparkdeletefilter where id in (select id from range(0, 2, 2));
delete from sparkdeletefilter where id in (select id from range(2, 4, 2));
delete from sparkdeletefilter where id in (select id from range(4, 6, 2));
select count(id) from sparkdeletefilter;and about half the time I get ConnectionPoolTimeoutException with Upd: I see what you mean - the parallelism is limited by available executor cores. In theory two connections should always be enough for an executor with one core. I will check it later. |
|
Thanks @danielcweeks , you are right, most probably I have a configuration issue: I've more executor cores than connections in the pool. Locally the example runs successfully with |
|
@danielcweeks , I've double checked production logs, I was wrong, in production I had no problem with the connection pool exhausted by data file connections, the timeouts were always caused by ManifestFilterManager #15713. The problem this PR addresses I only encountered locally, when I tried to reproduce ManifestFilterManager's issue by reducing max-connections. |
In spark data file loading holds a connection while lazy delete file loading tries to acquire another. When number of simultaneous connections is limited (for example by
http-client.apache.max-connections) it leads to a deadlock as soon as all connections are held by data files loading. To avoid the deadlock this PR adds delete file preloading to SparkDeleteFilter constructor.The problem can be reproduced using spark-sql with S3FileIO and
spark.sql.catalog.iceberg.http-client.apache.max-connections=1: