Repository navigation
Apply bigint migrations to build_events partitions and read from old/new columns instead - #6305
Merged
Merged
Conversation
Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
bigint-partitions
branch
from
November 29, 2020 23:28
1206de2 to
98f7717
Compare
rather than parsing out all the statements and supporting special syntax for transactionless migrations, just evaluate the whole content. the parsing was super brittle and would break if you used comments or special syntax in certain ways. we've been consistently adding BEGIN ... COMMIT in all our migrations, so it doesn't seem worth the hassle; if you need it to not run in a transaction, just don't add the BEGIN / COMMIT. Signed-off-by: Alex Suraci <[email protected]>
previously the build_id and build_id_old indexes were only applied to the parent table; they were not inherited by the child tables. child table indexes must be manually created. this migration loops over all existing pipelines and performs the same index dance that is done for the parent table. it also adds indexes for all team build events partitions and updates the trigger function to create them; they didn't exist before, and there doesn't seem to be a good reason not to do it. (team build events partitions are used for one-off builds.) note that newly created pipelines partitions will only have indexes for the new build_id bigint columns. we could update the trigger function to create both, but it really shouldn't be necessary; let's just let them go away when we finally drop the build_id_old column in the future. Signed-off-by: Alex Suraci <[email protected]>
previously this would only remove the events for one previous build. if there were many, i.e. if a user manually triggered a bunch, they would leak forever. now it will remove events for all builds that were removed. Signed-off-by: Alex Suraci <[email protected]>
this will make it so newly created pipelines *also* have build_id_old and build_id indexes, instead of just existing ones. this fixes the down migration. this will also be necessary for upcoming commits which bail on the batch migration approach and instead just query using both keys + indexes. Signed-off-by: Alex Suraci <[email protected]>
this didn't really work out; it was reasonably performant in local testing but extremely slow in production - even just the 'SELECT' query to find the start range for the batch took ~20 minutes. so rather than doing a long and painful migration, let's just query by build_id OR build_id_old - it should be fast enough since they're both indexed. we can phase out build_id_old when we redo how logs are stored and probably come up with an entirely new schema anyhow. Signed-off-by: Alex Suraci <[email protected]>
rather than performing an incredibly expensive migration affecting potentially hundreds of millions of rows, let's just make use of both indexes. this kicks the can down the road and leaves build_id_old around for now. if/when we get around to implementing something like concourse#3879 we can figure out a plan for phasing out build_events altogether. Signed-off-by: Alex Suraci <[email protected]>
using 'self' and 'this' is an anti-pattern; it should be named as if it is any other argument Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
bigint-partitions
branch
from
November 30, 2020 00:04
98f7717 to
491bca0
Compare
taylorsilva
approved these changes
Dec 1, 2020
taylorsilva
left a comment
Member
There was a problem hiding this comment.
LGTM. Reviewed the tests and did a little acceptance locally, everything looks good!
11 tasks
1 of 2 tasks
Member
|
This PR was a follow-up to #6203 for anyone else doing commit spelunking. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR accomplish?
Bug Fix
pipeline_build_events_Npartitions in the same way that they were updated forbuild_eventsteam_build_events_Npartitions (they were mysteriously missing).sqlmigrations by eliminating the statement parsing and just evaluating the file contents directlybuild_eventswhen creating new check buildsbuild_id(bigint) andbuild_id_old(integer) columns.Notes to reviewer:
In order to unclog the pipeline I have manually evaluated the
upmigration in theci.concourse-ci.orgenvironment. When we try to upgrade, the migrations will fail, so we should evaluate thedownmigration manually beforehand.Release Note
build_eventstable'sbuild_idcolumn tobigint, which we found to be too slow in large deployments, this PR adds a newbigintcolumn to thebuild_eventstable that is populated at runtimeContributor Checklist
Reviewer Checklist
BOSH and
Helm packaging; otherwise, ignored for
the integration
tests
(for example, if they are Garden configs that are not displayed in the
--helptext).