Skip to content

Conversation

@xuanyuanking
Copy link
Member

What changes were proposed in this pull request?

The implementation for the save operation of RocksDBFileManager.

Why are the changes needed?

Save all the files in the given local checkpoint directory as a committed version in DFS.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New UT added.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per #32272 (comment), we only generate the RocksDBLogFile object in the operation of saving checkpoint here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per #32272 (comment), we only use prettyJson in the log.

@SparkQA
Copy link

SparkQA commented May 18, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43206/

@dongjoon-hyun
Copy link
Member

cc @viirya

@SparkQA
Copy link

SparkQA commented May 18, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43206/

@viirya
Copy link
Member

viirya commented May 18, 2021

Thanks @dongjoon-hyun. I'll look at this.

@SparkQA
Copy link

SparkQA commented May 18, 2021

Test build #138685 has finished for PR 32582 at commit 5e6bf13.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class RocksDBFileManager(

@xuanyuanking xuanyuanking changed the title [WIP][SPARK-35436] RocksDBFileManager - save checkpoint to DFS [SPARK-35436] RocksDBFileManager - save checkpoint to DFS May 28, 2021
@xuanyuanking
Copy link
Member Author

As we merged #32272, after rebasing and addressing the comment, this one is ready for review. cc @viirya and @HeartSaVioR

@HeartSaVioR HeartSaVioR changed the title [SPARK-35436] RocksDBFileManager - save checkpoint to DFS [SPARK-35436][SS] RocksDBFileManager - save checkpoint to DFS May 28, 2021
@viirya
Copy link
Member

viirya commented May 28, 2021

Thanks @xuanyuanking. I will find some time to review this.

@SparkQA
Copy link

SparkQA commented May 28, 2021

Kubernetes integration test unable to build dist.

exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43559/

@SparkQA
Copy link

SparkQA commented May 28, 2021

Test build #139041 has finished for PR 32582 at commit 703f59f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class RocksDBFileManager(

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, could I safely assume versionToRocksDBFiles will be loaded when RocksDBFileManager is initialized with existing checkpoint in further PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. versionToRocksDBFiles was touched in the following 3 places:

  • saveCheckpointToDfs (this PR)
  • deleteOldVersions
  • loadCheckpointFromDfs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confusing here; if I understand correctly, we use version as batch ID + 1 for HDFSBackedStateStoreProvider, so version 0 with numKeys > 0 doesn't make sense at least for now. (As we don't have a functionality of "initial state" for now.)

How it works for RocksDB state store provider? Would the version be same with batch ID?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also use batch ID + 1 as the version for the RocksDB state store. Since the batch ID starts from -1 so for the corner case of the first empty batch (batch ID 0), we add the safeguard here to make sure the working dir is created.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about simply making sure the directory has been created in prior? We can add below in initialization and don't bother with handling specific case.

  // create a root directory on initialization if necessary
  if (!fm.exists(new Path(dfsRootDir))) {
    fm.mkdirs(new Path(dfsRootDir))
  }

If we'd like to avoid paying the cost on calling exist, let's keep the code and change the version to 1 as I met the case the version starts from 1 during test.

Copy link
Member Author

@xuanyuanking xuanyuanking Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's change the version to 1 for avoiding the extra cost of file operations. Will change it in the next commit. Done in bdd9e8e

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this, def listFiles(file: String) is probably unnecessary, as I expect implicit conversion happening when calling listFiles(file: File) with String.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right in this PR. In the further PRs, we will have more caller for the listFiles(file: String). Maybe let's keep it for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we have some code to check other files & metadata as well? We don't seem to cover the test on existence of zip file and the content.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll enhance this test in the next PR, RocksDBFileManager - load checkpoint from DFS, by load back the metadata and check the other files. Let me keep this conversation open and be referenced in the next PR.

Copy link
Member Author

@xuanyuanking xuanyuanking Jun 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HeartSaVioR
Copy link
Contributor

And I see lots of information regarding files will be printed out via INFO level. I don't know whether the information would make the log file being flooded, but I guess we want to leave the information for the first phase on ease of debugging. We could discuss to lower down the level if we are getting bothered from the log size.

@xuanyuanking
Copy link
Member Author

Great thanks for the detailed review! All comments addressed. Please take another look when you have time.
Regarding the logs, agree on more discussion about lower down some flooded messages. I'll also revisit other logs we add. For this PR, 7 INFO logs are for recoding file operations and metrics.

@SparkQA
Copy link

SparkQA commented Jun 2, 2021

Kubernetes integration test unable to build dist.

exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43744/

@SparkQA
Copy link

SparkQA commented Jun 2, 2021

Test build #139221 has finished for PR 32582 at commit 3800c51.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! The new changes look OK.

It would be nice if we can do the same we did for reviewing the first PR; if remaining review comments are planned to be addressed via further PR, please raise the PR so that we can refer the PR and finally approve this one.

@xuanyuanking
Copy link
Member Author

It would be nice if we can do the same we did for reviewing the first PR; if remaining review comments are planned to be addressed via further PR, please raise the PR so that we can refer the PR and finally approve this one.

Agree, let me submit the 3rd PR today.

The failure tests are not related, they can pass locally.

@viirya
Copy link
Member

viirya commented Jun 3, 2021

Sorry for late. I will take look this soon.

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through RocksDBFileManager, but not look at tests yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The zipped file is dfsZipFile, right? why filesStr here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fileStr contains the dfsZipFile name. The log format here is ${dfsZipFile} \n ${listing all the file names}

Comment on lines +113 to +114
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you talk more about there this claim (thread-safe) applies? Where we delete old files?

Do you mean versionToRocksDBFiles? When we prepare files for new version, there is another thread (maintenance thread) deleting old files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It refers to delete the files contained in the old versions. Here's the description of the deleteOldVersions method of RocksDBFileManager, which will be called in RocksDBStateStoreProvider.doMaintenance. As we did before, I'll also refer this comment when the PR for delete path submitted.

   * Delete old versions by deleting the associated version and SST files.
   * At a high-level, this method finds which versions to delete, and which SST files that were
   * last used in those versions. Its safe to delete these SST files because a SST file can
   * be reused only in successive versions. Therefore, if a SST file F was last used in version
   * V, then it wont be used in version V+1 or later, and if version V can be deleted, then
   * F can safely be deleted as well.

@SparkQA
Copy link

SparkQA commented Jun 3, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43809/

@SparkQA
Copy link

SparkQA commented Jun 3, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43809/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version = 1? In practice, will we save checkpoint files for same version? I.e. for same micro-batch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For task failover, it's possible that the tasks failed during uploading. The new task uses the same version and may schedule to the same executor but with different checkpoint dir.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use withTempDir too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will be further extended and more temp dir will be added. So maybe we just have the root path using withTempDir? See the demo here: https://github.com/apache/spark/pull/32767/files#diff-dc6f9dfe11e76f890ff2986f866853bcac263027c82562f9a52f4672a5460826R37

Comment on lines +98 to +99
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this will fail?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failed on purpose.

[info]   java.io.IOException: Copy failed intentionally
[info]   at org.apache.spark.sql.execution.streaming.CreateAtomicTestManager$$anon$3.close(CheckpointFileManagerSuite.scala:169)

This test aims to test the behavior that the cancel should be called no matter any error happens during close. See the comment and code here: https://github.com/apache/spark/pull/32582/files#diff-e3d3914d0398d61fdd299b1f8d3e869ec6a86e97606677c724969e421c9bf44eR222-R227

@SparkQA
Copy link

SparkQA commented Jun 4, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43862/

@SparkQA
Copy link

SparkQA commented Jun 4, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43862/

@SparkQA
Copy link

SparkQA commented Jun 4, 2021

Test build #139340 has finished for PR 32582 at commit bdd9e8e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@xuanyuanking
Copy link
Member Author

Gentle ping @viirya @HeartSaVioR Do you think this is ready to go?

@viirya
Copy link
Member

viirya commented Jun 8, 2021

Thanks @xuanyuanking for the work. Let's move forward to next related PR.

@HeartSaVioR
Copy link
Contributor

I'll merge once either build test passes.

@HeartSaVioR
Copy link
Contributor

retest this, please

@xuanyuanking
Copy link
Member Author

Thanks @viirya. Let me retrigger the test.

@SparkQA
Copy link

SparkQA commented Jun 9, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/44041/

@SparkQA
Copy link

SparkQA commented Jun 9, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/44041/

@SparkQA
Copy link

SparkQA commented Jun 9, 2021

Test build #139516 has finished for PR 32582 at commit f86cea4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HeartSaVioR
Copy link
Contributor

Thanks! Merging to master.

@HeartSaVioR
Copy link
Contributor

Thanks @xuanyuanking for your contribution! I merged this to master branch.

@SparkQA
Copy link

SparkQA commented Jun 9, 2021

Kubernetes integration test unable to build dist.

exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/44054/

@SparkQA
Copy link

SparkQA commented Jun 9, 2021

Test build #139529 has finished for PR 32582 at commit c05b140.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@xuanyuanking xuanyuanking deleted the SPARK-35436 branch June 9, 2021 06:26
@xuanyuanking
Copy link
Member Author

Great thanks for the help! @HeartSaVioR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants