-
Notifications
You must be signed in to change notification settings - Fork 10
fix(registry): cron-repair stored membership status/is_ended that go stale with the clock #418
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
Changes from all commits
3a8348d
f80ccf3
aba3aa6
43feda5
3575819
c905f8a
f31fd28
bf34983
a53e6af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <odoo noupdate="1"> | ||
| <!-- Daily full safety net: repairs stored status/is_ended once they | ||
| disagree with the clock, including NULL / non-ORM drift whose | ||
| probes need full table scans; see _cron_recompute_ended_status | ||
| (#417). user_id is pinned to the superuser on both crons: the | ||
| unsudo'd repair searches rely on it to see memberships of | ||
| disabled registrants (two global ir.rule records hide those | ||
| otherwise). --> | ||
| <record id="cron_recompute_membership_ended_status" model="ir.cron"> | ||
| <field name="name">Registry: Recompute Ended Group Memberships</field> | ||
| <field name="model_id" ref="model_spp_group_membership" /> | ||
| <field name="state">code</field> | ||
| <field name="code">model._cron_recompute_ended_status()</field> | ||
| <field name="interval_number">1</field> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking refinement: the exact transition time is known when
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adopted — |
||
| <field name="interval_type">days</field> | ||
| <field name="user_id" ref="base.user_root" /> | ||
| <!-- Two hours after install/upgrade: clear of the post-upgrade | ||
| load spike (nothing is stale that recently), and an hour | ||
| behind the crossed cron below so the two never start | ||
| sweeping their shared crossed legs at the same moment. Both | ||
| are daily, so that offset holds on every later run. On a | ||
| shared nextcall two cron workers take the two jobs at once | ||
| and UPDATE the same rows, and REPEATABLE READ kills whichever | ||
| commits second. --> | ||
| <field | ||
| name="nextcall" | ||
| eval="(DateTime.now() + timedelta(hours=2)).strftime('%Y-%m-%d %H:%M:%S')" | ||
| /> | ||
| <field name="active" eval="True" /> | ||
| </record> | ||
|
|
||
| <!-- Trigger target: writes of a future ended_date _trigger this cron | ||
| in the minute after that moment, so it can run many times a day | ||
| and sweeps only the two index-served clock-crossed legs; see | ||
| _cron_repair_crossed_ended_status. Its own daily schedule is | ||
| cheap redundancy. --> | ||
| <record id="cron_repair_crossed_membership_ended_status" model="ir.cron"> | ||
| <field name="name">Registry: Repair Clock-Crossed Group Memberships</field> | ||
| <field name="model_id" ref="model_spp_group_membership" /> | ||
| <field name="state">code</field> | ||
| <field name="code">model._cron_repair_crossed_ended_status()</field> | ||
| <field name="interval_number">1</field> | ||
| <field name="interval_type">days</field> | ||
| <field name="user_id" ref="base.user_root" /> | ||
| <field | ||
| name="nextcall" | ||
| eval="(DateTime.now() + timedelta(hours=1)).strftime('%Y-%m-%d %H:%M:%S')" | ||
| /> | ||
| <field name="active" eval="True" /> | ||
| </record> | ||
| </odoo> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardening nit: with no
user_id, the cron runs as the data-load default (OdooBot, superuser) — which is what makes the unsudo'd searches immune to the two global disabled-registrantir.rules on this model. If an operator ever reassigns the Scheduler User to a non-superuser, memberships of disabled registrants silently stop being repaired. Pinning<field name="user_id" ref="base.user_root"/>(as the spp_dci crons do) makes the assumption explicit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied —
user_idpinned tobase.user_rootwith the reasoning in a comment beside it, andtest_cron_repairs_memberships_of_disabled_registrantsnow pins the behaviour itself: an officer-run sweep misses a disabled registrant's stale membership, the root-run sweep repairs it.