Skip to content

[GOBBLIN-1847] Exceptions in the JobLauncher should try to delete the existing workflow if it is launched#3711

Merged
ZihanLi58 merged 2 commits intoapache:masterfrom
homatthew:mh-dont-fail-if-zk-exception-ETL-14877
Jun 28, 2023
Merged

[GOBBLIN-1847] Exceptions in the JobLauncher should try to delete the existing workflow if it is launched#3711
ZihanLi58 merged 2 commits intoapache:masterfrom
homatthew:mh-dont-fail-if-zk-exception-ETL-14877

Conversation

@homatthew
Copy link
Copy Markdown
Contributor

@homatthew homatthew commented Jun 27, 2023

Dear Gobblin maintainers,

Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!

JIRA

Description

  • Here are some details about my PR, including screenshots (if applicable):
    If the JobLauncher encounters any errors, Gobblin code cleans up the working directory that contains Gobblin state. But we do not clean up the helix workflows. This can cause us to spin up helix workflows that do not have valid Gobblin State on HDFS / S3.

When this occurs, it causes rapid container recycling, which puts tremendous load on Zookeeper due to Helix API calls, causing a peak in ZK callbacks

image

The cancellation logic is obnoxious, so here is the high level of what happens.

  1. Calling AbstractJobLauncher#cancelJob(JobListener) sets AbstractJobLauncher#cancellationRequested to true
  2. This causes the AbstractJobLauncher#cancellationExecutor created by the AbstractJobLauncher#startCancellationExecutor() method to call the abstract method AbstractJobLauncher#executeCancellation()
  3. That method implemented in GobblinHelixJobLauncher#executeCancellation(), which eventually calls HelixUtils.cancelWorkflow(...)

Considerations

  • I considered modifying the runWorkunits itself since that is where the cleanup directory is called. But I wanted to leverage the existing the cancellation request logic (which is admittedly super overkill and has a ton of concurrency). We also collect a ton of metrics during the cancellation process, so it's important that I call the cancel method that is part of the AbstractJobLauncher. Since we need access to the job listener, it makes most sense to have it be part of the launchJob method

  • The reason I clean up even when there is a successful finish, is because there isn't really a reason not to cancel a workflow to run after the job is finished for Fast Ingest. The cancel call is safe to call multiple times and there are clearly still edge cases where we don't call cancel properly

  • I am not a fan of adding a new flag, but I want to maintain backward compatibility since this job launcher is used beyond Fast Ingest

Testing

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:
    image

Commits

  • My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

// then call still properly call cancel. We use the listener to confirm the cancel hook was correctly called once
JobListener mockListener = Mockito.mock(JobListener.class);
gobblinHelixJobLauncher.launchJob(mockListener);
Mockito.verify(mockListener).onJobCancellation(Mockito.any(JobContext.class));
Copy link
Copy Markdown
Contributor Author

@homatthew homatthew Jun 27, 2023

Choose a reason for hiding this comment

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

Fun fact: verify without a parameter verifies the method is called exactly once! 😃

@homatthew homatthew force-pushed the mh-dont-fail-if-zk-exception-ETL-14877 branch from 6776637 to 77d5f0d Compare June 27, 2023 05:29
@homatthew homatthew force-pushed the mh-dont-fail-if-zk-exception-ETL-14877 branch from 77d5f0d to 7c42987 Compare June 27, 2023 17:41
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 27, 2023

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 46.86%. Comparing base (fc508ca) to head (cabb968).
⚠️ Report is 420 commits behind head on master.

Files with missing lines Patch % Lines
...pache/gobblin/cluster/GobblinHelixJobLauncher.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3711      +/-   ##
============================================
- Coverage     46.87%   46.86%   -0.01%     
- Complexity    10771    10808      +37     
============================================
  Files          2138     2141       +3     
  Lines         84139    84433     +294     
  Branches       9357     9386      +29     
============================================
+ Hits          39436    39569     +133     
- Misses        41102    41264     +162     
+ Partials       3601     3600       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@ZihanLi58 ZihanLi58 left a comment

Choose a reason for hiding this comment

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

+1

@ZihanLi58 ZihanLi58 merged commit b6b49c7 into apache:master Jun 28, 2023
phet added a commit to phet/gobblin that referenced this pull request Aug 15, 2023
* upstream/master:
  Fix bug with total count watermark whitelist (apache#3724)
  [GOBBLIN-1858] Fix logs relating to multi-active lease arbiter (apache#3720)
  [GOBBLIN-1838] Introduce total count based completion watermark (apache#3701)
  Correct num of failures (apache#3722)
  [GOBBLIN- 1856] Add flow trigger handler leasing metrics (apache#3717)
  [GOBBLIN-1857] Add override flag to force generate a job execution id based on gobbl… (apache#3719)
  [GOBBLIN-1855] Metadata writer tests do not work in isolation after upgrading to Iceberg 1.2.0 (apache#3718)
  Remove unused ORC writer code (apache#3710)
  [GOBBLIN-1853] Reduce # of Hive calls during schema related updates (apache#3716)
  [GOBBLIN-1851] Unit tests for MysqlMultiActiveLeaseArbiter with Single Participant (apache#3715)
  [GOBBLIN-1848] Add tags to dagmanager metrics for extensibility (apache#3712)
  [GOBBLIN-1849] Add Flow Group & Name to Job Config for Job Scheduler (apache#3713)
  [GOBBLIN-1841] Move disabling of current live instances to the GobblinClusterManager startup (apache#3708)
  [GOBBLIN-1840] Helix Job scheduler should not try to replace running workflow if within configured time (apache#3704)
  [GOBBLIN-1847] Exceptions in the JobLauncher should try to delete the existing workflow if it is launched (apache#3711)
  [GOBBLIN-1842] Add timers to GobblinMCEWriter (apache#3703)
  [GOBBLIN-1844] Ignore workflows marked for deletion when calculating container count (apache#3709)
  [GOBBLIN-1846] Validate Multi-active Scheduler with Logs (apache#3707)
  [GOBBLIN-1845] Changes parallelstream to stream in DatasetsFinderFilteringDecorator  to avoid classloader issues in spark (apache#3706)
  [GOBBLIN-1843] Utility for detecting non optional unions should convert dataset urn to hive compatible format (apache#3705)
  [GOBBLIN-1837] Implement multi-active, non blocking for leader host (apache#3700)
  [GOBBLIN-1835]Upgrade Iceberg Version from 0.11.1 to 1.2.0 (apache#3697)
  Update CHANGELOG to reflect changes in 0.17.0
  Reserving 0.18.0 version for next release
  [GOBBLIN-1836] Ensuring Task Reliability: Handling Job Cancellation and Graceful Exits for Error-Free Completion (apache#3699)
  [GOBBLIN-1805] Check watermark for the most recent hour for quiet topics (apache#3698)
  [GOBBLIN-1825]Hive retention job should fail if deleting underlying files fail (apache#3687)
  [GOBBLIN-1823] Improving Container Calculation and Allocation Methodology (apache#3692)
  [GOBBLIN-1830] Improving Container Transition Tracking in Streaming Data Ingestion (apache#3693)
  [GOBBLIN-1833]Emit Completeness watermark information in snapshotCommitEvent (apache#3696)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants