Merge lp://qastaging/~cjwatson/launchpad/db-bugsummary-statement-triggers into lp://qastaging/launchpad/db-devel
Status: | Rejected |
---|---|
Rejected by: | Colin Watson |
Proposed branch: | lp://qastaging/~cjwatson/launchpad/db-bugsummary-statement-triggers |
Merge into: | lp://qastaging/launchpad/db-devel |
Diff against target: |
274 lines (+255/-3) 2 files modified
database/schema/patch-2210-06-0.sql (+251/-0) database/schema/security.cfg (+4/-3) |
To merge this branch: | bzr merge lp://qastaging/~cjwatson/launchpad/db-bugsummary-statement-triggers |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stuart Bishop | db | Pending | |
Launchpad code reviewers | db | Pending | |
Review via email: mp+371297@code.qastaging.launchpad.net |
Commit message
Rewrite BugSummary triggers to be statement-level.
Description of the change
Rewrite the BugSummaryJournal maintenance triggers to make use of the new transition tables provided to AFTER ... FOR EACH STATEMENT triggers as of PostgreSQL 10. Instead of using row-level triggers which accumulate changes in a temporary table and flush it into the journal, we now write directly to the journal at the end of each statement.
There's a considerable amount of complexity here due to transition tables only being visible in the trigger function itself, not in functions that it calls. I used a combination of LATERAL and dynamic commands to minimise the amount of repeated code resulting from this. This does mean that the outermost part of each trigger function's query needs to be replanned each time the trigger runs, but I don't expect that to make a significant performance difference.
The transformations related to bug tags aren't completely obvious. I eliminated summarise_bug and unsummarise_bug from the call chain, as they didn't seem to be pulling their weight. When BugTag is changed, rather than decrementing/
I can't say for sure whether this will fix the periodic bug update timeouts we've been seeing, since we've never completely got to the bottom of their cause. However, reducing the number of times the trigger functions need to be called and eliminating their use of an explicit temporary table seem likely to improve matters.
Unmerged revisions
- 14125. By Colin Watson
-
Rewrite BugSummary triggers to be statement-level.
Superseded by https:/ /code.launchpad .net/~cjwatson/ launchpad/ +git/launchpad/ +merge/ 373765.