Skip to content

Fixes Missing Reminders From Empty Caches#1919

Closed
HassanAbouelela wants to merge 13 commits into
mainfrom
reminders-fetch
Closed

Fixes Missing Reminders From Empty Caches#1919
HassanAbouelela wants to merge 13 commits into
mainfrom
reminders-fetch

Conversation

@HassanAbouelela
Copy link
Copy Markdown
Contributor

Blocked by python-discord/site#618.
See #1916 for more info. This PR shouldn't close that issue.

I updated the reminders cog to try and get around the issue with missing users in the cache during startup. To try and resolve that issue, I switched to fetching as a fallback if the user wasn't found. To avoid accidentally hammering the discord API with fetch requests at startup, I removed the validity checks from the init function, instead opting to only run the check during the send function. It doesn't cost much to fail the task later.

@HassanAbouelela HassanAbouelela added t: bug Something isn't working a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) p: 1 - high High Priority a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) labels Oct 28, 2021
@HassanAbouelela HassanAbouelela changed the title Adds Get-Fetch User Utility Fixes Missing Reminders From Empty Caches Oct 29, 2021
@HassanAbouelela HassanAbouelela added review: do not merge The PR can be reviewed but cannot be merged now and removed review: do not merge The PR can be reviewed but cannot be merged now labels Oct 29, 2021
Duplicates the `get_or_fetch_member` utility for users.
Refractors the reminders cog to not check for users in cache during
startup, when they are most likely to be missing.

Tries to fetch from the discord API if user could not be found in cache.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
@ChrisLovering ChrisLovering removed the review: do not merge The PR can be reviewed but cannot be merged now label Nov 7, 2021
@Xithrius Xithrius added the s: needs review Author is waiting for someone to review and approve label Dec 15, 2021
Comment thread bot/exts/utils/reminders.py Outdated
Comment thread bot/exts/utils/reminders.py Outdated
Comment thread bot/exts/utils/reminders.py Outdated
Comment thread bot/exts/utils/reminders.py Outdated
Comment thread bot/exts/utils/reminders.py Outdated
@onerandomusername
Copy link
Copy Markdown
Contributor

This is no longer blocked by python-discord/site#618 as its been merged!

Copy link
Copy Markdown
Contributor

@jchristgit jchristgit left a comment

Choose a reason for hiding this comment

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

Hassan my beloved

After Mark's comments are addressed, this looks good to me.

@wookie184 wookie184 added s: waiting for author Waiting for author to address a review or respond to a comment and removed s: needs review Author is waiting for someone to review and approve labels Jan 17, 2022
@Xithrius Xithrius added up for grabs Available for anyone to work on and removed s: waiting for author Waiting for author to address a review or respond to a comment labels Jan 21, 2022
@Xithrius Xithrius requested review from ChrisLovering, kosayoda and scragly and removed request for ChrisLovering and ks129 February 15, 2022 00:49
@Xithrius
Copy link
Copy Markdown
Contributor

Xithrius commented Feb 15, 2022

Bumping this PR, would anyone like to take over? This is still in high priority.

@Xithrius Xithrius added p: 2 - normal Normal Priority and removed p: 1 - high High Priority labels May 27, 2022
MarkKoz added 6 commits May 28, 2022 16:04
Keeping ensure_valid_reminder separate wasn't improving readability;
it required a complex return type.
Inactive reminders aren't used anywhere, so they may as well just be
deleted.
It's only used for a mention, which can trivially be created manually.
Both try_send_reminder and send_reminder delete the reminder, so
allowing them both to run simultaneously for the same reminder could
lead to a race condition. Admittedly, it'd be quite rare, since it'd
require the reminder to become invalid after send_reminder has been
called.
@MarkKoz MarkKoz self-assigned this May 28, 2022
@MarkKoz MarkKoz removed the up for grabs Available for anyone to work on label May 28, 2022
MarkKoz added 3 commits May 28, 2022 16:42
The exact time isn't used, so it's simpler to just used a boolean to
determine whether the reminder is late.
@MarkKoz
Copy link
Copy Markdown
Contributor

MarkKoz commented May 29, 2022

In hindsight, the DB should have been modified to store the timestamp of the last send attempt rather than a count of failures. The latter approach is flawed because if the bot restarts immediately after failing, it will instantly try again rather than waiting.

@wookie184
Copy link
Copy Markdown
Contributor

Hmmm. Given #2080 should have fixed the original issue, I'm not sure what the benefit of this retry approach is any more.

@MarkKoz
Copy link
Copy Markdown
Contributor

MarkKoz commented May 29, 2022

Hmmm. Given #2080 should have fixed the original issue, I'm not sure what the benefit of this retry approach is any more.

It fixed it by doing away with the author check. This means it still sends the reminder even if the user left the server.

@wookie184
Copy link
Copy Markdown
Contributor

Hmmm. Given #2080 should have fixed the original issue, I'm not sure what the benefit of this retry approach is any more.

It fixed it by doing away with the author check. This means it still sends the reminder even if the user left the server.

Doesn't fetch_user still get the user if they're not on the server, so this would do the same? If we use get_or_fetch_member then it should only (and always as it isn't reliant on cache) return the member if they're on the server, so the retry logic wouldn't be necessary.

@MarkKoz
Copy link
Copy Markdown
Contributor

MarkKoz commented May 29, 2022

@wookie184 Yes, actually. I guess I don't know what the point is. @HassanAbouelela ?

@HassanAbouelela
Copy link
Copy Markdown
Contributor Author

This PR was written before that one and opted not to do away with the checks. If we don't care about the check anymore, then this is redundant.

@MarkKoz
Copy link
Copy Markdown
Contributor

MarkKoz commented May 29, 2022

I'm going to close this then. I don't see any benefit to checking the user if it can't reliably know whether they're in the guild.

@MarkKoz MarkKoz closed this May 29, 2022
@ChrisLovering ChrisLovering deleted the reminders-fetch branch August 16, 2023 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) p: 2 - normal Normal Priority t: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants