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
F14378096: D16912.id40714.diff
Sat, Dec 21, 1:56 AM
Unknown Object (File)
Thu, Dec 19, 10:17 AM
Unknown Object (File)
Thu, Dec 19, 9:57 AM
Unknown Object (File)
Thu, Dec 19, 7:02 AM
Unknown Object (File)
Thu, Dec 19, 3:07 AM
Unknown Object (File)
Thu, Dec 19, 3:07 AM
Unknown Object (File)
Thu, Dec 19, 3:07 AM
Unknown Object (File)
Thu, Dec 19, 3:07 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.