Skip to content

[GOBBLIN-1778] Add house keeping thread in DagManager to periodically sync in memory state with mysql table#3635

Merged
ZihanLi58 merged 5 commits intoapache:masterfrom
ZihanLi58:GOOBLIN-1778
Feb 6, 2023
Merged

[GOBBLIN-1778] Add house keeping thread in DagManager to periodically sync in memory state with mysql table#3635
ZihanLi58 merged 5 commits intoapache:masterfrom
ZihanLi58:GOOBLIN-1778

Conversation

@ZihanLi58
Copy link
Copy Markdown
Contributor

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):
    Now dag managers have the assumption that it is the only process that can update mysql table and the in-memory state is always in sync with mysql. But we do notice that during the leader transforms period, it's possible that two dag manager can run concurrently and update the mysql db at the same time.

To address that, we need either add a lock to make sure only one dag manager is working at one time, or we need to have a housekeeping thread to periodically sync the in-memory state with the mysql table. After discussion, we choose to go with the later approach and we do have the assumption that GaaS submit jobs without specifying job.id, so jobs with same flow execution id will not share the staging dir and can be executed concurrently.

Besides that, during adding test, I figure out there will be NPE if we try to set the dag manager as inactive, add a small fix for that as well.

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:
    Just add a single thread for housekeeping so will not affect other functions. Also add unit test to make sure we close the thread when de-active DagManager to avoid memory leak

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"

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 2, 2023

Codecov Report

Merging #3635 (f635acd) into master (9f8ab24) will increase coverage by 6.42%.
The diff coverage is 54.83%.

@@             Coverage Diff              @@
##             master    #3635      +/-   ##
============================================
+ Coverage     40.16%   46.58%   +6.42%     
- Complexity     3544    10672    +7128     
============================================
  Files           791     2133    +1342     
  Lines         33285    83558   +50273     
  Branches       3699     9290    +5591     
============================================
+ Hits          13368    38924   +25556     
- Misses        18601    41069   +22468     
- Partials       1316     3565    +2249     
Impacted Files Coverage Δ
...org/apache/gobblin/metrics/InnerMetricContext.java 55.67% <0.00%> (ø)
...rvice/modules/orchestration/DagManagerMetrics.java 87.25% <0.00%> (ø)
...blin/service/modules/orchestration/DagManager.java 83.06% <60.71%> (ø)
...lin/util/filesystem/FileSystemInstrumentation.java 85.71% <0.00%> (-7.15%) ⬇️
...a/org/apache/gobblin/cluster/GobblinHelixTask.java 60.21% <0.00%> (-2.16%) ⬇️
...in/java/org/apache/gobblin/cluster/HelixUtils.java 44.44% <0.00%> (-1.67%) ⬇️
...obblin/recordaccess/AvroGenericRecordAccessor.java 72.80% <0.00%> (ø)
...blin/writer/initializer/NoopWriterInitializer.java 0.00% <0.00%> (ø)
.../gobblin/runtime/api/JobSpecSchedulerListener.java 100.00% <0.00%> (ø)
...g/apache/gobblin/util/io/GsonInterfaceAdapter.java 66.12% <0.00%> (ø)
... and 1339 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment on lines +278 to +280
if (!this.isActive) {
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would this ever cause dags to be missed? If during the process where one new dag is being added and then the leader is changed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh good catch, I add the check in the load dag method to avoid this scenario.

}
}

private void loadingDagsFromDagStateStore() throws IOException {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tiny grammar nit: rename to loadDagFromDagStateStore? Since when it reads it's more declarative

addDag(dag, false, false);
loadingDagsFromDagStateStore();
this.houseKeepingThreadPool = Executors.newSingleThreadScheduledExecutor();
for (int delay = houseKeepingThreadInitialDelay; delay < 180; delay *= 2) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

make 180 a static variable named: MAX_HOUSEKEEPING_THREAD_DELAY ?

@ZihanLi58 ZihanLi58 merged commit 9e0a2be into apache:master Feb 6, 2023
umustafi pushed a commit to umustafi/gobblin that referenced this pull request Feb 8, 2023
… sync in memory state with mysql table (apache#3635)

* address comments

* use connectionmanager when httpclient is not cloesable

* [GOBBLIN-1778] Add house keeping thread in DagManager to periodically sync in memory state with mysql table

* fix unit test

* address comments

---------

Co-authored-by: Zihan Li <zihli@zihli-mn2.linkedin.biz>
phet added a commit to phet/gobblin that referenced this pull request Feb 13, 2023
* upstream/master:
  [GOBBLIN-1774] Util for detecting non optional uniontypes Hive tables (apache#3632)
  [GOBBLIN-1773] Fix bugs in quota manager (apache#3636)
  [GOBBLIN-1782] Fix Merge State for Flow Pending Resume statuses (apache#3639)
  [GOBBLIN-1755] Support extended ACLs and sticky bit for file based distcp (apache#3616)
  [GOBBLIN-1780] Refactor/rename YarnServiceIT to YarnServiceTest (apache#3637)
  [GOBBLIN-1778] Add house keeping thread in DagManager to periodically sync in memory state with mysql table (apache#3635)
  Register gauge metrics for change monitors (apache#3634)
phet added a commit to phet/gobblin that referenced this pull request Mar 24, 2023
* upstream/master:
  [GOBBLIN-1774] Util for detecting non optional uniontypes Hive tables (apache#3632)
  [GOBBLIN-1773] Fix bugs in quota manager (apache#3636)
  [GOBBLIN-1782] Fix Merge State for Flow Pending Resume statuses (apache#3639)
  [GOBBLIN-1755] Support extended ACLs and sticky bit for file based distcp (apache#3616)
  [GOBBLIN-1780] Refactor/rename YarnServiceIT to YarnServiceTest (apache#3637)
  [GOBBLIN-1778] Add house keeping thread in DagManager to periodically sync in memory state with mysql table (apache#3635)
  Register gauge metrics for change monitors (apache#3634)
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