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

Expire runs that have no session, just warn while doing so #317

Merged
merged 1 commit into from
Jul 14, 2020

Conversation

nicpottier
Copy link
Member

Explored our DB for old runs that weren't archived / deleted and found that those that were sticking around were runs that no longer had a session. It isn't super clear at this point what the root cause is there, from the RapidPro session culling code we only cull sessions that have ended, so this points to events where somehow we update a session without updating a flowrun, which I don't see any possibility for on the Mailroom side.

In any case, once we are in this state there's nothing to do be done. So this change moves forward with expiring these runs but warns to sentry about it so we can continue to track what may be occurring in updating the flow runs while still building valid archives.

@nicpottier nicpottier requested a review from rowanseymour July 14, 2020 14:44
@codecov
Copy link

codecov bot commented Jul 14, 2020

Codecov Report

Merging #317 into master will increase coverage by 0.01%.
The diff coverage is 54.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #317      +/-   ##
==========================================
+ Coverage   53.21%   53.22%   +0.01%     
==========================================
  Files         100      100              
  Lines        8624     8628       +4     
==========================================
+ Hits         4589     4592       +3     
- Misses       3344     3345       +1     
  Partials      691      691              
Impacted Files Coverage Δ
models/runs.go 0.00% <0.00%> (ø)
tasks/expirations/cron.go 53.33% <100.00%> (+2.45%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecd2a10...d29e150. Read the comment docs.

ContactID models.ContactID `db:"contact_id"`
RunID models.FlowRunID `db:"run_id"`
ParentUUID *flows.RunUUID `db:"parent_uuid"`
SessionID *models.SessionID `db:"session_id"`
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we generally model null ids like NilSessionID = SessionID(0) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do both in various places. I'm not positive what the right thing is but I've kind of settled that if the TYPE can be null normally, then having a nullable type derived from null.Int makes sense, but if not then selecting to a pointer is more correct. IE, within Mailroom are we ever "setting" null.

In this case SessionID being nil is very much the exception and this is the only places that looks at that possibility so using a pointer made sense to me. We get to keep the "stricter" type elsewhere. (and have things fail if we try to select a NULL into that stricter type)

Happy to change if you disagree.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense 👍

@nicpottier nicpottier merged commit 669030a into master Jul 14, 2020
@nicpottier nicpottier deleted the expire-empty-sessions branch July 14, 2020 15:39
rasoro pushed a commit to Ilhasoft/mailroom that referenced this pull request Mar 10, 2023
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.

2 participants