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

Adding total timeout to task models #313

Merged
merged 6 commits into from
Nov 27, 2024

Conversation

shaileshpadave
Copy link
Contributor

@shaileshpadave shaileshpadave commented Nov 19, 2024

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • WHOSUSING.md
  • Other (please describe):

Changes in this PR

Added new parameter total task timeout to taskmodel and task def. This will be useful to timeout task if it exceeds total timeout value (including timeout in retry as well), this PR is only for model changes. Core service changes will be in another PR.

@shaileshpadave shaileshpadave force-pushed the addTotalTimeout branch 4 times, most recently from 95851be to 039e8af Compare November 19, 2024 15:01
@@ -202,6 +202,9 @@ public boolean isRetriable() {
@ProtoField(id = 42)
private boolean subworkflowChanged;

@ProtoField(id = 43)
private long firstStartTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

should be added to equals, hashcode and toString?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I think we should change the hashCode to be aware of the task's PK -- which is taskName. Thoughts @jmigueprieto

Copy link
Contributor

Choose a reason for hiding this comment

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

@v1r3n hashCode is considering taskDefName

  @Override
    public int hashCode() {
        return Objects.hash(
                getTaskType(),
                getStatus(),
                getInputData(),
                getReferenceTaskName(),
                getWorkflowPriority(),
                getRetryCount(),
                getSeq(),
                getCorrelationId(),
                getPollCount(),
                getTaskDefName(),
                ...
}

Or do you want to use just "task name"?
PROS

  • It will be simpler
  • (small) Performance gain

CONS

  • We'll need to modify equals: if only id is used in hashCode but equals considers additional fields, the contract will be broken.
  • We'll have an incomplete equality: this might break existing code e.g.: tests that assert assertNotEquals(task0, task1). If both task have the same name but different fields, the assertion is true now but will be false is we just consider task name.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can analyze this further in another PR. But, for the moment I believe that we should stick to considering the added fields to equals and hashCode

/**
* @return the total timeout in seconds
*/
public long getTotalTimeoutSeconds() {
Copy link
Contributor

Choose a reason for hiding this comment

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

equals & hashCode?

@@ -142,11 +146,17 @@ public TaskDef(String name, String description) {
this.description = description;
}

public TaskDef(String name, String description, int retryCount, long timeoutSeconds) {
public TaskDef(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can a new constructor be added instead of changing the signature of this one?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

@jmigueprieto jmigueprieto left a comment

Choose a reason for hiding this comment

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

  • There are changes to backend and client v4 - split this PR.
  • The client changes are breaking changes. Do NOT modify the signature of existing constructors. They might be in use by someone and adding a property should NOT break existing code.

@shaileshpadave shaileshpadave force-pushed the addTotalTimeout branch 2 times, most recently from cfd6396 to 31f4487 Compare November 25, 2024 08:49
@shaileshpadave shaileshpadave changed the title Adding total timeout to task Adding total timeout to task models Nov 25, 2024
return totalTimeoutSeconds;
}

public void setTotalTimeoutSeconds(@NotNull long totalTimeoutSeconds) {
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: a long (primitive type) cannot be null. The @NotNull is redundant.

Copy link
Contributor

@jmigueprieto jmigueprieto left a comment

Choose a reason for hiding this comment

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

LGTM after NIT changes

@shaileshpadave shaileshpadave merged commit c67b2eb into conductor-oss:main Nov 27, 2024
2 checks passed
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