Submitting Changes
Tags: reliability, releases, software
Published: 2022-04-07 16:31:43

---
title: Submitting Changes
published: true
date: 2022-04-05 16:55:00 UTC
tags: Reliability,Releases,Software
canonical_url: https://kevincox.ca/2022/04/05/submitting-changes/
---

<main><aside><p>This is part of a three part series on rollouts. Where I envision what an ideal rollout process would look like if sufficient tool support existed.</p>
<ol>
<li><a href="https://kevincox.ca/2022/03/18/multi-version-rollout/">Multi-Version Rollouts</a></li>
<li>
<a href="https://kevincox.ca/2022/04/05/submitting-changes/">When to Submit a Change</a> (this article)</li>
<li>Delinearized Rollouts (to be written)</li>
</ol></aside><hr>
<p>Most places I have seen have the following workflow:</p>
<ol>
<li>Submit patch for review.</li>
<li>Ensure that the tests pass.</li>
<li>Get approval from a reviewer.</li>
<li>Merge patch with the development branch.</li>
<li>Code is deployed to production.</li>
</ol>
<p>The seems pretty reasonable. In theory your main branch is always “good” because the tests need to pass before merge. This means that developers can always base a new patch off of the development branch and have a good base to build off of.</p>
<p>However, there are some problems:</p>
<h2 id="semantic-merge-conflicts"><a href="https://kevincox.ca/2022/04/05/submitting-changes/#semantic-merge-conflicts">Semantic Merge Conflicts</a></h2>
<p>The first problem is that there may be conflicts when you merge. Imagine that one patch renames <code>foo()</code> to <code>bar()</code> and another patch uses <code>foo()</code>. Both pass tests independently but fail to compile when added together.</p>
<p>This issue can be solved via a simple <a href="https://kevincox.ca/2020/08/15/git-green-ci/">merge queue, as I have explained previously</a>.</p>
<h2 id="tests-dont-catch-everything">Tests Don’t Catch Everything</h2>
<p>As discussed in <a href="https://kevincox.ca/2022/03/18/multi-version-rollout/">Part 1</a> a change has only received light testing by the time code review completes. To really be tested we need integration testing (the type that probably takes hours for a complex program) and actual production use.</p>
<h2 id="delayed-submission"><a href="https://kevincox.ca/2022/04/05/submitting-changes/#delayed-submission">Delayed Submission</a></h2>
<p>We can improve the situation by changing when we think of code as “submitted”. We take the idea of a merge queue and push it further. Your code isn’t submitted when you press “merge”. Your code isn’t even submitted when the unit tests pass on the merged result. Your code isn’t even merged when integration tests pass. Your code is only “submitted” when it has been running in production for a day.</p>
<p>That may be extreme, but let’s look at the possibilities.</p>
<h3 id="pros"><a href="https://kevincox.ca/2022/04/05/submitting-changes/#pros">Pros</a></h3>
<h4 id="free-reverts">“Free” Reverts</h4>
<p>Rollbacks for submitted changes are difficult because it is possible that later changes make rollbacks non-clean. When the changes aren’t “submitted” yet you can simply drop the patch from the queue without worrying about changing commits that people depend on.</p>
<p>In fact the whole way of thinking about changes can be changed. Instead of a point in the workflow where changes are “locked-in” by adding them to the main development branch that choice can be made arbitrarily based on the probability that each commit is “good”. At some point that probability passes a threshold and the patch is “submitted” which means that new work is based upon it by default but is harder to revert if needed.</p>
<h4 id="reduces-pipeline-stalls"><a href="https://kevincox.ca/2022/04/05/submitting-changes/#reduces-pipeline-stalls">Reduces Pipeline Stalls</a></h4>
<p>If you base your new feature off of a bad version this may slow you down for a number of reasons:</p>
<ul>
<li>Development might be more difficult due to the breakage.</li>
<li>Existing failing tests may prevent progression of the patch.</li>
<li>The patch can’t be deployed to production with the broken base (without reverts on top).</li>
</ul>
<p>By basing your change on code that is very likely to be good you avoid these problems. In general the older the version you use as a base the less likely that it has unknown defects. So by delaying publishing new patches until they are very well tested the probability of these pipeline stalls decreases.</p>
<h3 id="cons"><a href="https://kevincox.ca/2022/04/05/submitting-changes/#cons">Cons</a></h3>
<h4 id="dependencies"><a href="https://kevincox.ca/2022/04/05/submitting-changes/#dependencies">Dependencies</a></h4>
<p>One complication is that it is harder to depend on previous code. With “classic” merging as soon as the button is pressed it is available in the development repo. But now it is possible to have a merge conflict with in-flight code. Your code can’t be enqueued because it conflicts with other code that is in the queue (or it can be enqueued hoping that the other patch fails) but you can’t do the regular rebase on top of the latest development branch because the conflicting code isn’t there yet.</p>
<p>Luckily this is fairly natural to resolve with Git. If you want to depend on an in-flight commit just base your branch on it. Then if your commit is merged that dependency will be merged too. (Of course if the dependency has problem your commit will also get rejected, but this would typically occur for classic reverts anyways, just more manual.) Ideally the tool managing merges would make this simple, it can tell you which in-flight commits your change conflicts with so that you can base yourself on top of them if desired.</p>
<p>Semantic conflicts can still be an issue (someone adds a test or lint that your patch fails) but these tend to be infrequent so shouldn’t be an issue for reasonable in-flight times (hours or days, not weeks).</p>
<h4 id="tooling-required"><a href="https://kevincox.ca/2022/04/05/submitting-changes/#tooling-required">Tooling Required</a></h4>
<p>Setting this up requires a fairly complex version manager with full control over deployment as well as integration with your monitoring and <abbr title="Source Code Management">SCM</abbr>. The logic of this tool wouldn’t be particularly complex, but it needs to support a wide variety of backends. Advanced evaluation processes would also need lots of configuration for defining statistical comparisons between different versions and logic for batching, splitting and rollups.</p>
<p>It would be possible to do a simple version manually, manually deploy to a slice of production after approval. However, merge conflicts would cause a lot of pain and forgotten versions that were never cleaned up would cause bugs and outages.</p>
<p>A quality implementation would likely also want to integrate with the app to provide hard-coded per-user routing to provide specific users access to early preview and the ability to test fixes on users who are experiencing the problems.</p></main>