@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Straighten out replication/cache behavior in "bin/storage dump"

Summary:
Fixes T13336.

- Prevent `--no-indexes` from being combined with `--for-replica`, since combining these options can only lead to heartbreak.
- In `--for-replica` mode, dump caches too. See discussion in T13336. It is probably "safe" to not dump these today, but fragile and not correct.
- Mark the "MarkupCache" table as having "Cache" persistence, not "Data" persistence (no need to back it up, since it can be fully regenerated from other datasources).

Test Plan: Ran `bin/storage dump` with various combinations of flags.

Maniphest Tasks: T13336

Differential Revision: https://secure.phabricator.com/D20743

+34 -7
+4
src/applications/cache/storage/PhabricatorMarkupCache.php
··· 30 30 ) + parent::getConfiguration(); 31 31 } 32 32 33 + public function getSchemaPersistence() { 34 + return PhabricatorConfigTableSchema::PERSISTENCE_CACHE; 35 + } 36 + 33 37 }
+9 -1
src/applications/config/schema/PhabricatorConfigSchemaSpec.php
··· 48 48 abstract public function buildSchemata(); 49 49 50 50 protected function buildLiskObjectSchema(PhabricatorLiskDAO $object) { 51 + $index_options = array(); 52 + 53 + $persistence = $object->getSchemaPersistence(); 54 + if ($persistence !== null) { 55 + $index_options['persistence'] = $persistence; 56 + } 57 + 51 58 $this->buildRawSchema( 52 59 $object->getApplicationName(), 53 60 $object->getTableName(), 54 61 $object->getSchemaColumns(), 55 - $object->getSchemaKeys()); 62 + $object->getSchemaKeys(), 63 + $index_options); 56 64 } 57 65 58 66 protected function buildFerretIndexSchema(PhabricatorFerretEngine $engine) {
+4
src/infrastructure/storage/lisk/LiskDAO.php
··· 1881 1881 ->getMaximumByteLengthForDataType($data_type); 1882 1882 } 1883 1883 1884 + public function getSchemaPersistence() { 1885 + return null; 1886 + } 1887 + 1884 1888 1885 1889 /* -( AphrontDatabaseTableRefInterface )----------------------------------- */ 1886 1890
+17 -6
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
··· 14 14 'name' => 'for-replica', 15 15 'help' => pht( 16 16 'Add __--master-data__ to the __mysqldump__ command, '. 17 - 'generating a CHANGE MASTER statement in the output.'), 17 + 'generating a CHANGE MASTER statement in the output. This '. 18 + 'option also dumps all data, including caches.'), 18 19 ), 19 20 array( 20 21 'name' => 'output', ··· 54 55 $output_file = $args->getArg('output'); 55 56 $is_compress = $args->getArg('compress'); 56 57 $is_overwrite = $args->getArg('overwrite'); 58 + $is_noindex = $args->getArg('no-indexes'); 59 + $is_replica = $args->getArg('for-replica'); 57 60 58 61 if ($is_compress) { 59 62 if ($output_file === null) { ··· 79 82 } 80 83 } 81 84 85 + if ($is_replica && $is_noindex) { 86 + throw new PhutilArgumentUsageException( 87 + pht( 88 + 'The "--for-replica" flag can not be used with the '. 89 + '"--no-indexes" flag. Replication dumps must contain a complete '. 90 + 'representation of database state.')); 91 + } 92 + 82 93 if ($output_file !== null) { 83 94 if (Filesystem::pathExists($output_file)) { 84 95 if (!$is_overwrite) { ··· 93 104 94 105 $api = $this->getSingleAPI(); 95 106 $patches = $this->getPatches(); 96 - 97 - $with_indexes = !$args->getArg('no-indexes'); 98 107 99 108 $applied = $api->getAppliedPatches(); 100 109 if ($applied === null) { ··· 119 128 $schemata = $actual_map[$ref_key]; 120 129 $expect = $expect_map[$ref_key]; 121 130 131 + $with_caches = $is_replica; 132 + $with_indexes = !$is_noindex; 133 + 122 134 $targets = array(); 123 135 foreach ($schemata->getDatabases() as $database_name => $database) { 124 136 $expect_database = $expect->getDatabase($database_name); ··· 143 155 // When dumping tables, leave the data in cache tables in the 144 156 // database. This will be automatically rebuild after the data 145 157 // is restored and does not need to be persisted in backups. 146 - $with_data = false; 158 + $with_data = $with_caches; 147 159 break; 148 160 case PhabricatorConfigTableSchema::PERSISTENCE_INDEX: 149 161 // When dumping tables, leave index data behind of the caller ··· 183 195 $argv[] = '--default-character-set'; 184 196 $argv[] = $api->getClientCharset(); 185 197 186 - if ($args->getArg('for-replica')) { 198 + if ($is_replica) { 187 199 $argv[] = '--master-data'; 188 200 } 189 201 ··· 341 353 342 354 return 0; 343 355 } 344 - 345 356 346 357 private function writeData($data, $file, $is_compress, $output_file) { 347 358 if (!strlen($data)) {