Page MenuHomePhabricator

Apply storage patches patch-by-patch, not database-by-database
ClosedPublic

Authored by epriestley on Nov 22 2016, 2:07 PM.
Tags
None
Referenced Files
F14347744: D16912.id40719.diff
Thu, Dec 19, 3:07 AM
F14347743: D16912.id40715.diff
Thu, Dec 19, 3:07 AM
F14347742: D16912.id40714.diff
Thu, Dec 19, 3:07 AM
F14347741: D16912.id.diff
Thu, Dec 19, 3:07 AM
F14347739: D16912.diff
Thu, Dec 19, 3:07 AM
Unknown Object (File)
Tue, Dec 17, 9:56 AM
Unknown Object (File)
Fri, Dec 13, 1:57 PM
Unknown Object (File)
Tue, Dec 10, 11:55 AM
Subscribers
None

Details

Summary

Ref T11044. Sometimes we have a sequence of patches like this:

  • 01.newtable.sql: Adds a new table to Files.
  • 02.movedata.php: Moves some data that used to live in Tokens to the new table.

This is fairly rare, but not unheard of. More commonly, we can have this sequence:

  • 03.newtable.sql: Add a new column to Phame.
  • 04.setvalue.php: Copy data into that new column.

In both cases, when applying database-by-database, we can get into trouble.

  • In the first case, if Files is on a different master, we'll try to move data into a new table before creating the table.
  • In the second case, if Phame is on a different master, the PHP patch will connect to it before we add the new column.

In either case, we try to interact with tables or columns which don't exist yet.

Instead, apply each patch in order, to all databases which need it. So we'll apply 01.newtable.sql EVERYWHERE first, then move on.

In the case of PHP patches, we also now only apply them once, since they never make schema changes. It should normally be OK to apply them more than once safely, but this is a little faster and a little safer if we ever make a mistake.

Test Plan
  • Ran bin/storage upgrade on single-host and clustered setups.
  • Initialized new storage on single-host and clustered setups.
  • Upgraded again after initialization.
  • Ran with --apply.
  • Ran with --dry-run.

Diff Detail

Repository
rP Phabricator
Branch
partition8
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 14609
Build 19072: Run Core Tests
Build 19071: arc lint + arc unit

Event Timeline

epriestley retitled this revision from to Apply storage patches patch-by-patch, not database-by-database.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
  • Fix a bad interaction between --apply and --force.
chad edited edge metadata.
This revision is now accepted and ready to land.Nov 22 2016, 4:56 PM
This revision was automatically updated to reflect the committed changes.