-
Notifications
You must be signed in to change notification settings - Fork 333
WPB-26823: make meetings cleanup fully index-driven #5328
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
Open
blackheaven
wants to merge
9
commits into
develop
Choose a base branch
from
gdifolco/WPB-26823-meeting-index
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+189
−12
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
54be945
WPB-26823: make meetings cleanup fully index-driven
blackheaven 8503715
Hello CI
blackheaven b99485d
Hello CI
blackheaven 374e31a
Hello CI
blackheaven 787219b
Hello CI
blackheaven 6dd6a70
Hello CI
blackheaven b39dce5
Hello CI
blackheaven 4e10ff8
fix(sven): use the effective time instead of end time
blackheaven 33f8315
WPB-26823: add meetings_recurrence_consistency CHECK constraint
blackheaven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Added partial indexes and rewrote the meetings cleanup query so the background | ||
| worker stays fully index-driven as the `meetings` table grows: | ||
| - `idx_meetings_recurrence_eff_end` on `GREATEST(end_time, recurrence_until)` | ||
| for bounded recurring meetings (covers the recurring branches of the list and | ||
| cleanup queries). | ||
| - `idx_meetings_end_time_nonrecurring` on `end_time` for non-recurring meetings, | ||
| so cleanup can find expired non-recurring meetings without scanning | ||
| not-yet-expired recurring rows whose original slot is long past. | ||
| `getOldMeetingsImpl` now issues one bounded, index-backed query per meeting kind | ||
| and merges the two batches in Haskell. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Added a `meetings_recurrence_consistency` CHECK constraint so the recurrence | ||
| columns can never be left in a partially-set state (frequency is the master | ||
| switch; interval is required when set; recurrence_until stays optional for | ||
| open-ended recurring meetings). |
27 changes: 27 additions & 0 deletions
27
.../wire-subsystems/postgres-migrations/20260708090000-meetings-recurrence-eff-end-index.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2026 Wire Swiss GmbH <[email protected]> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| -- Partial expression index for the recurring-meeting branches of | ||
| -- listMeetingsByUserImpl, listMeetingsByConversationImpl and | ||
| -- getOldMeetingsImpl, which filter/order on | ||
| -- GREATEST(end_time, recurrence_until). Non-recurring meetings keep using | ||
| -- idx_meetings_end_time. See WPB-26823. | ||
| CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_meetings_recurrence_eff_end | ||
| ON meetings (GREATEST(end_time, recurrence_until)) | ||
| WHERE recurrence_frequency IS NOT NULL | ||
| AND recurrence_interval IS NOT NULL | ||
| AND recurrence_until IS NOT NULL; |
24 changes: 24 additions & 0 deletions
24
...re-subsystems/postgres-migrations/20260708100000-meetings-end-time-nonrecurring-index.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2026 Wire Swiss GmbH <[email protected]> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| -- Partial index for the non-recurring branch of getOldMeetingsImpl, so the | ||
| -- cleanup worker can find expired non-recurring meetings ordered by end_time | ||
| -- without scanning not-yet-expired recurring meetings (which carry an old | ||
| -- end_time but a recurrence window still open in the future). See WPB-26823. | ||
| CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_meetings_end_time_nonrecurring | ||
| ON meetings (end_time) | ||
| WHERE recurrence_frequency IS NULL; |
32 changes: 32 additions & 0 deletions
32
...systems/postgres-migrations/20260713120000-meetings-recurrence-consistency-constraint.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2026 Wire Swiss GmbH <[email protected]> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| -- Migration: add CHECK constraint enforcing meetings recurrence consistency. | ||
| -- Description: recurrence_frequency is the master switch. NULL => non-recurring | ||
| -- (interval and until must be NULL). NOT NULL => recurring, which requires | ||
| -- interval NOT NULL; recurrence_until stays optional (open-ended recurring | ||
|
Check warning on line 21 in libs/wire-subsystems/postgres-migrations/20260713120000-meetings-recurrence-consistency-constraint.sql
|
||
| -- meetings never expire and are intentionally excluded from cleanup). | ||
|
|
||
| ALTER TABLE meetings | ||
| ADD CONSTRAINT meetings_recurrence_consistency CHECK ( | ||
| (recurrence_frequency IS NULL | ||
| AND recurrence_interval IS NULL | ||
| AND recurrence_until IS NULL) | ||
| OR | ||
| (recurrence_frequency IS NOT NULL | ||
| AND recurrence_interval IS NOT NULL) | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Might be good to document why we're using two queries here. (Not that some future incarnation of myself accidentally optimizes this away... 😉 )