Skip to content

Conversation

@baohe-zhang
Copy link

What changes were proposed in this pull request?

This pull request adds 2 test suites for 2 new classes HybridStore and HistoryServerMemoryManager, which were created in #28412. This pull request also did some minor changes in these 2 classes to expose some variables for testing. Besides 2 suites, this pull request adds a unit test in FsHistoryProviderSuite to test parsing logs with HybridStore.

Why are the changes needed?

Unit tests are needed for new features.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Unit tests.

@baohe-zhang
Copy link
Author

cc @gatorsmile @HeartSaVioR ^^ Unit tests for #28412.

@SparkQA
Copy link

SparkQA commented Aug 21, 2020

Test build #127750 has finished for PR 29509 at commit e5ec236.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@baohe-zhang
Copy link
Author

cc @tgravescs @redsanket ^^

@SparkQA
Copy link

SparkQA commented Aug 21, 2020

Test build #127751 has finished for PR 29509 at commit 9043b7a.

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

@SparkQA
Copy link

SparkQA commented Aug 21, 2020

Test build #127761 has finished for PR 29509 at commit b3eacc3.

  • 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 patch. Done the first round of review.

// Use InMemoryStore to rebuild app store
while (hybridStore == null) {
// A RuntimeException will be thrown if the heap memory is not sufficient
memoryManager.lease(appId, attempt.info.attemptId, reader.totalSize,
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, previous code looks better, as it doesn't require FsHistoryProvider to know about the details on memory manager. Is this related to the test code?

Copy link
Author

Choose a reason for hiding this comment

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

It's related to the test code, but my original thought is that passing the actual amount of memory, instead of filesize to memoryManager.lease() would make more sense. Although exposing inner details to fsHistoryProvider is not ideal. What's your opinion? Should I revert this change?

Copy link
Contributor

@HeartSaVioR HeartSaVioR Aug 24, 2020

Choose a reason for hiding this comment

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

Previous code looks consistent with HistoryDiskManager. Let's leave it as it is.

If we really want to make the approximate memory calculation be separate and be exposed to others, I guess it no longer needs to be class method. It may be method of the util object, which also contain the approximate disk usage as well. (so both will keep consistent after the change) Probably better to do it in separate PR if you think it looks to be a good change.

Copy link
Author

Choose a reason for hiding this comment

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

Make sense, I've reverted the changes on lease().


if (!inMemory) {
conf.set(LOCAL_STORE_DIR, Utils.createTempDir().getAbsolutePath())
if (useHybridStore) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is affected by the default value of config (suppose the default value becomes true) - we'd be better to just assign.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

if (switch) switchHybridStore(store)

intercept[NoSuchElementException] {
store.read(t2.getClass(), t2.key)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: indent seems to be broken

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

val listener = new SwitchListener()
store.switchToLevelDB(listener, "test", None)
assert(listener.waitUntilDone())
while (!store.getStore().isInstanceOf[LevelDB]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we need to wait more after waiting listener? Or just to make sure?

Copy link
Author

Choose a reason for hiding this comment

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

There is a potential race in https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/deploy/history/HybridStore.scala#L154. So we need this while loop to ensure the shouldUseInMemoryStore is set to false.

assert(store.getStore().isInstanceOf[InMemoryStore])
val listener = new SwitchListener()
store.switchToLevelDB(listener, "test", None)
assert(listener.waitUntilDone())
Copy link
Contributor

Choose a reason for hiding this comment

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

Please introduce test timeout to avoid hang on possible (future) bugs, either here or waitUntilDone().

Copy link
Author

Choose a reason for hiding this comment

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

failAfter() added here.


private class SwitchListener extends HybridStore.SwitchToLevelDBListener {

private val results = new LinkedBlockingQueue[Int]()
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just simplify it - true/false would be sufficient. If in doubt we can leave one line comment to explain the meaning of true/false.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed, using boolean directly.

@SparkQA
Copy link

SparkQA commented Aug 24, 2020

Test build #127826 has finished for PR 29509 at commit 1b105e3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class HybridStoreSuite extends SparkFunSuite with BeforeAndAfter with TimeLimits

@SparkQA
Copy link

SparkQA commented Aug 24, 2020

Test build #127846 has finished for PR 29509 at commit f83d2df.

  • This patch fails Spark unit 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.

LGTM pending test

@HeartSaVioR
Copy link
Contributor

retest this, please

@SparkQA
Copy link

SparkQA commented Aug 25, 2020

Test build #127861 has finished for PR 29509 at commit f83d2df.

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

@HeartSaVioR
Copy link
Contributor

Thanks @baohe-zhang for the PR! Merged into master.

@baohe-zhang
Copy link
Author

@HeartSaVioR Thanks for the review!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants