iceberg: DeleteOrphanFiles or ExpireSnapshots outofmemory
`` ` Column joinCond = nameEqual.and(actualContains); List<String> orphanFiles = actualFileDF.join(validFileDF, joinCond, “leftanti”) .as(Encoders.STRING()) .collectAsList();
Tasks.foreach(orphanFiles)
.noRetry()
.suppressFailureWhenFinished()
.onFailure((file, exc) -> LOG.warn("Failed to delete file: {}", file, exc))
.run(deleteFunc::accept);`
spark all path collect to driver,When there are too many files,outofmemory ,It doesn’t make sense, Deletion should be performed directly on the cluster rather than being collected to the driver for deletion,I can’t carry it out now
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 2
- Comments: 18 (8 by maintainers)
This worked for me.
The approach I took was to take 1 pass without setting that flag then if there was a failure automatically re-try with that flag set. That way I wouldn’t be potentially introducing a performance regression when it wasn’t necessary.
This could be done automatically in the iceberg project itself. I think this will repeatedly come up and would like to have expireSnapshots “just work” without extra glue code/config management needed by users.
Let me know if you’re welcome to any contributions with this approach.
above settings helped to solve the issue for us
ok, we found something in our environment. Disabling binPacking suddenly released this “leak” what we think is that ContextCleaner component of spark that is responsible for cleanup of broadcasts is not keeping up with all the tasks it has. We see steady increase of referenceQueue length. Most probably most of the tasks there are of type cleanAcum, so those are kind of blocking broadcasts to be cleaned automatically. Imo it’s best to cleanup those explicitly. Meanwhile we are going to try spark.cleaner.referenceTracking.blocking false and to reduce spark.cleaner.periodicGC.interval to some minimum possible , so that cleaner will kick in immediately.
It seems that after all it’s related to broadcast that happens unconditionally in contentFileDS method the broadcast variable contains SerializableTableWithSize which is accumulated over time if same action is run in the same driver there is no code that unpersists this broadcast. I can’t see a reason why setting spark.sql.autoBroadcastJoinThreshold=-1 should help here, since this is core spark api and not sql api
we running maintenance jobs as part of long living spark context and see memory accumulating under memoryStore and it’s related to ExpireSnapshotsSparkAction lambdas see following screenshot from memory analyzer
the objects that are stored there are related to SerializableTableWithSize object somehow
I don’t understand yet how, but imo it’s this::doExecute call inside
@RussellSpitzer I wonder where we are now for this issue.