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

feat: Use built-in retry features of Celery when retrying Credentials grading tasks #34074

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

justinhynes
Copy link
Contributor

Description

This PR updates the send_grade_to_credentials task to use built-in features of Celery to handle task retries. We believe the current exponential backoff and retry mechanism is too aggressive and can cause issues overloading Credentials when many grade updates occur at once (because of a big notify_credentials run or a regrade kicked off by a change to a grading policy in a course).

max_retries=10,
retry_backoff=30,
retry_backoff_max=600,
retry_jitter=True,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Total number that each individual task will be attempted stays the same (11 -- initial attempt + 10 retries).

This change updates the time period before an initial retry. Before it was 1s, now it will be "some number" between 1s - 30s (because we are also going to use Celery's jittering functionality to stagger retried tasks).

The backoff will double each time to a maximum of 600s (10 minutes). The original implementation went about 30m, but this felt really long. I'm hoping that if we space out retries a bit more, if Credentials doesn't get overloaded then we can process the tasks quicker.

While I believe retry_jitter is enabled by default, I added it as an argument for verbosity.

@justinhynes justinhynes marked this pull request as ready for review January 18, 2024 20:09
@@ -43,12 +42,16 @@
CertificateStatuses.downloadable,
]

# Maximum number of retries before giving up. For reference, 11 retries with exponential backoff yields a maximum
# waiting time of 2047 seconds (about 30 minutes). Setting this to None could yield unwanted behavior: infinite retries.
MAX_RETRIES = 11
Copy link
Member

Choose a reason for hiding this comment

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

[nonblocking] is there a particular reason why you took this out of being the constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just figured we didn't need it anymore, with the number of retries being part of the task declaration. It was only used in the retry logic for this task too, and I didn't think it needed to be a constant anymore.

Copy link
Member

@deborahgu deborahgu left a comment

Choose a reason for hiding this comment

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

I left a question and a non-blocking comment -- I don't see a reason to stop using the constant for max retries (just called in the decorator and the test in the same way), but I think it's fine either way.

'verified': verified,
'lms_last_updated_at': grade_last_updated
}
logger.info(f"Running task `send_grade_to_credentials` for username {username} with data: {data}")
Copy link
Member

Choose a reason for hiding this comment

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

[question] Is this considered safe information for our logs? it's not exactly PII – it's just a username and grades, nothing personally identifiable – but I wanted to make sure we consider that a safe update.

to be clear, I'm not saying it's not. I just assume we have standards about what you can send the logs and what you can't, & I don't know them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is one of those "stuck between a rock and a hard place" logging decisions for me. I'm trying to value what would be valuable for debugging, balanced against what potential PII are we logging. Over the years, we've tried really hard NOT to log username (and log LMS User Id instead as the identifier in logs)... but Credentials mostly cares about username.

I thought the value of having some insight as to what we're sending to Credentials is more valuable than keeping the username out of our logs. AFAIK it's a strong preference, not a hard requirement to exclude info like username (which I do think is considered PII).

Copy link
Member

Choose a reason for hiding this comment

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

yeah, that makes sense. I was more worried about sending the username with the grade, but that's not really PII by any definition, even if it is something the user would expect to have extra privacy applied to. :shipit:

@justinhynes justinhynes merged commit 18775cb into master Jan 22, 2024
63 checks passed
@justinhynes justinhynes deleted the jhynes/APER-3121 branch January 22, 2024 18:37
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

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