Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GOBBLIN-1875] Create Unique Trigger Keys #3737

Merged
merged 4 commits into from
Aug 15, 2023

Conversation

umustafi
Copy link
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):
    We are seeing the following errors when trying to schedule reminders for Multi-active scheduler after losing lease acquisition:
    Unable to store Trigger with name: '...' and group: '...' because one already exists with this identification
    The Quartz scheduler allows multiple unique triggers mapping to one job in a N:1 relation, but this requires the trigger having a unique identifier associated with it. When we create triggers, we were previously using only the job name and group to identify the trigger so we're unable to add additional triggers for the same job. The trigger key is only used internally by the Quartz scheduler, so it is safe to manipulate by adding a random number to identify the trigger. We also don't expect more than a handful of triggers associated with a job, so an int 0 to 1000 will be sufficient to uniquely identify the trigger.

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:
    testCreateUniqueTriggersForJob creates two triggers with the same job key and verifies the trigger key's are unique

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"

return TriggerBuilder.newTrigger()
.withIdentity(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY),
.withIdentity(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY) + random.nextInt(1000),
Copy link
Contributor

Choose a reason for hiding this comment

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

Random number will make it super hard to debug if something went wrong.. does it make sense to change the trigger name to be normal flow name -> normal trigger that tigger the execution; {flowName + “reminder job” + executionid/timestamp} -> reminder job for a specific execution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated with this!

Copy link
Contributor

@phet phet left a comment

Choose a reason for hiding this comment

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

very close!

* @return
*/
public static String createSuffixForJobTrigger(long eventToRevisitMillis) {
return "reminder_for_" + (eventToRevisitMillis);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why the parens?

*/
public static Trigger createTriggerForJob(JobKey jobKey, Properties jobProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you verify that this method is not called anywhere else? Asking because this is a backward incompatible change. You can leave this method and make it by default a call to createTriggerForJob(jobKey, jobProps, Optional.absent())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I checked everywhere and added. It would not compile otherwise also.

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2023

Codecov Report

Merging #3737 (cb63e59) into master (7dbf7b6) will decrease coverage by 1.77%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master    #3737      +/-   ##
============================================
- Coverage     47.08%   45.31%   -1.77%     
+ Complexity    10864     2139    -8725     
============================================
  Files          2147      413    -1734     
  Lines         84825    17956   -66869     
  Branches       9412     2184    -7228     
============================================
- Hits          39936     8137   -31799     
+ Misses        41264     8952   -32312     
+ Partials       3625      867    -2758     

see 1735 files with indirect coverage changes

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

Copy link
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 24e63e8 into apache:master Aug 15, 2023
6 checks passed
This pull request was closed.
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.

4 participants