hudi icon indicating copy to clipboard operation
hudi copied to clipboard

[SUPPORT]Clean up does not seem to happen on MOR table

Open luffyd opened this issue 6 years ago • 6 comments

Tips before filing an issue

  • Have you gone through our FAQs? yes

  • Join the mailing list to engage in conversations and get faster support at [email protected].

  • If you have triaged this as a bug, then file an issue directly.

Describe the problem you faced

I have a simple while(true) in which I have been committing data to hudi for MOR table. I was able to add successfully >1000 commits. But I noticed the table size kept growing continuously and no clean jobs have been run.

Used hudi cli command cleans show to confirm this

I did run cleans run and it cleaned lots of data. After the run data size became 500GB from 25TB .

To Reproduce

Steps to reproduce the behavior:

Code snippet to run: val startTime = System.currentTimeMillis()

  val parallelism = options.getOrElse("parallelism", Math.max(2, upsertCount/100000).toString).toInt
  println("parallelism", parallelism)
  (inputDF
    .write
    .format("org.apache.hudi")
    .option(HoodieWriteConfig.TABLE_NAME, options.getOrElse("tableName", "facestest"))
    .option(DataSourceWriteOptions.STORAGE_TYPE_OPT_KEY, DataSourceWriteOptions.MOR_STORAGE_TYPE_OPT_VAL)
    .option(DataSourceWriteOptions.PARTITIONPATH_FIELD_OPT_KEY, "partitionKey")
    .option(DataSourceWriteOptions.RECORDKEY_FIELD_OPT_KEY, "nodeId")
    .option(DataSourceWriteOptions.PRECOMBINE_FIELD_OPT_KEY, "ts")
    .option(DataSourceWriteOptions.OPERATION_OPT_KEY, DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL)
    .option("hoodie.upsert.shuffle.parallelism", parallelism)//not the ideal way but works
    .option("hoodie.bulkinsert.shuffle.parallelism", parallelism)//not the ideal way but works

    .mode(SaveMode.Append)
    .save(getHudiPath(spark)))

  val endTime = System.currentTimeMillis()
  val diff = endTime - startTime
  timings = diff :: timings
  CloudWatchWriter.addTimeMetric("faceUpsertTimeForLoop_"+run, diff, spark.sparkContext.isLocal)

Expected behavior

Clean jobs should have ran.

Environment Description

  • Hudi version : 0.5.3

  • Spark version : 2.4

  • Storage (HDFS/S3/GCS..) : S3

  • Running on Docker? (yes/no) : no

Additional context

Adding some loggin and used hudi-cli to rectify the situation.

I did run cleans run and it cleaned lots of data. After the run data size became 500GB from 25TB .

I am guessing this line is resolving to false and clean up was never triggered. https://github.com/apache/hudi/blob/master/hudi-client/src/main/java/org/apache/hudi/table/action/clean/CleanPlanner.java#L354

Stacktrace

Hudi Trace logs

20/07/21 23:09:10 INFO FileSystemViewHandler: TimeTakenMillis[Total=2647, Refresh=2646, handle=1, Check=0], Success=true, Query=basepath=s3%3A%2F%2Fchelan-dev-mock-faces%2FTestFacesUpserForLoop%2Feight&lastinstantts=20200721225935&timelinehash=44494fd19bd1c8ab3d67910abfd9
06fe922a8c118ec2279044f586278833480b, Host=ip-10-0-1-147.us-west-2.compute.internal:41753, synced=true
20/07/21 23:09:10 INFO CleanPlanner: No earliest commit to retain. No need to scan partitions !!
20/07/21 23:09:10 INFO CleanActionExecutor: Nothing to clean here. It is already clean

*** Some custom logging in the application***

 val metaClient = new HoodieTableMetaClient(spark.sparkContext.hadoopConfiguration, getHudiPath(spark), true)
     println("metaClient.getActiveTimeline().countInstants()", metaClient.getActiveTimeline().countInstants())
     println("metaClient.getCommitTimeline.filterCompletedInstants.countInstants()", metaClient.getCommitTimeline.filterCompletedInstants.countInstants())
     println("metaClient.getCommitTimeline.filterCompletedAndCompactionInstants.countInstants()", metaClient.getCommitTimeline.filterCompletedAndCompactionInstants().countInstants())

Results for above:

(metaClient.getActiveTimeline().countInstants(),33)
(metaClient.getCommitTimeline.filterCompletedInstants.countInstants(),4)
(metaClient.getCommitTimeline.filterCompletedAndCompactionInstants.countInstants(),4)

luffyd avatar Jul 23 '20 20:07 luffyd

Hi @luffyd

By default, upsert on MOR tables creates 'deltacommits'. Compaction needs to run to convert deltacommits into commits. Clean works only after compaction runs and commits are created. Clean also does not remove file groups that have pending compaction. Can you setup inline compaction using instructions here for testing and see if that helps?

If that doesn't work, can you share screenshot of files in .hoodie folder in 'getHudiPath'

satishkotha avatar Jul 24 '20 00:07 satishkotha

Thanks saitsh, I have inline turned on by default, Now I see cleans did happen! Is there a possibility that commits get archived before clean job is resulting in a noop. I will continue to monitor.

Also can you confirm If I can run a clean job in a separate spark job concurrently while streaming write is happening, guess it should be fine as compaction runs have that ability

luffyd avatar Jul 24 '20 17:07 luffyd

Is there a possibility that commits get archived before clean job is resulting in a noop. I will continue to monitor.

clean and archival are somewhat independent today. So this 'noop' should not happen.

Also can you confirm If I can run a clean job in a separate spark job concurrently while streaming write is happening, guess it should be fine as compaction runs have that ability

Why are you considering separate spark job for clean? Are you seeing clean take a lot of time? You can consider running clean concurrently with write by setting 'hoodie.clean.async' to true. (This runs clean in same job, but concurrently with write).

I don't know of anyone using separate spark job to run clean. Theoretically, I think it is possible. But you may have to do some testing because it isn't used like this afaik.

satishkotha avatar Jul 24 '20 18:07 satishkotha

Ok thanks No I was not thinking to run as separate process continuously, but I wanted to execute "clean commands" from cli o that my streaming tests progress faster.

luffyd avatar Jul 24 '20 21:07 luffyd

Sounds good. Please try it and let me know if you see any issues.

satishkotha avatar Jul 24 '20 22:07 satishkotha

Please resolve this, Cleans are happening fine.

I also added, I think it comes at the expense of timeline feature. We will relax it later ` val compactionConfig = HoodieCompactionConfig.newBuilder() .withCleanerPolicy(HoodieCleaningPolicy.KEEP_LATEST_FILE_VERSIONS) .retainFileVersions(1) .build() val writerConfig = HoodieWriteConfig.newBuilder() .withCompactionConfig(compactionConfig) .withPath(getHudiPath(spark)) .build() val writeClient = new HoodieWriteClient(spark.sparkContext, writerConfig)

// Run cleaner
val cleanStats = writeClient.clean()

`

luffyd avatar Aug 04 '20 15:08 luffyd