@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.

Record more details about where a write is taking place while holding a cluster lock

Summary: Ref T4292. This will let the UI and future `bin/repository` tools give administrators more tools to understand problems when reporting or resolving them.

Test Plan:
- Pushed fully clean repository.
- Pushed previously-pushed repository.
- Forced write to abort, inspected useful information in the database.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4292

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

+29 -9
+2
resources/sql/autopatches/20160418.repoversion.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_repository.repository_workingcopyversion 2 + ADD writeProperties LONGTEXT COLLATE {$COLLATE_TEXT};
+2 -1
src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php
··· 26 26 $command = csprintf('git-receive-pack %s', $repository->getLocalPath()); 27 27 28 28 $did_synchronize = true; 29 - $repository->synchronizeWorkingCopyBeforeWrite(); 29 + $viewer = $this->getUser(); 30 + $repository->synchronizeWorkingCopyBeforeWrite($viewer); 30 31 } 31 32 32 33 $caught = null;
+8 -2
src/applications/repository/storage/PhabricatorRepository.php
··· 2482 2482 /** 2483 2483 * @task sync 2484 2484 */ 2485 - public function synchronizeWorkingCopyBeforeWrite() { 2485 + public function synchronizeWorkingCopyBeforeWrite( 2486 + PhabricatorUser $actor) { 2486 2487 if (!$this->shouldEnableSynchronization()) { 2487 2488 return; 2488 2489 } ··· 2516 2517 2517 2518 PhabricatorRepositoryWorkingCopyVersion::willWrite( 2518 2519 $repository_phid, 2519 - $device_phid); 2520 + $device_phid, 2521 + array( 2522 + 'userPHID' => $actor->getPHID(), 2523 + 'epoch' => PhabricatorTime::getNow(), 2524 + 'devicePHID' => $device_phid, 2525 + )); 2520 2526 2521 2527 $this->clusterWriteVersion = $max_version; 2522 2528 $this->clusterWriteLock = $write_lock;
+17 -6
src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php
··· 7 7 protected $devicePHID; 8 8 protected $repositoryVersion; 9 9 protected $isWriting; 10 + protected $writeProperties; 10 11 11 12 protected function getConfiguration() { 12 13 return array( ··· 14 15 self::CONFIG_COLUMN_SCHEMA => array( 15 16 'repositoryVersion' => 'uint32', 16 17 'isWriting' => 'bool', 18 + 'writeProperties' => 'text?', 17 19 ), 18 20 self::CONFIG_KEY_SCHEMA => array( 19 21 'key_workingcopy' => array( ··· 66 68 * lock is released by default. This is a durable lock which stays locked 67 69 * by default. 68 70 */ 69 - public static function willWrite($repository_phid, $device_phid) { 71 + public static function willWrite( 72 + $repository_phid, 73 + $device_phid, 74 + array $write_properties) { 70 75 $version = new self(); 71 76 $conn_w = $version->establishConnection('w'); 72 77 $table = $version->getTableName(); ··· 74 79 queryfx( 75 80 $conn_w, 76 81 'INSERT INTO %T 77 - (repositoryPHID, devicePHID, repositoryVersion, isWriting) 82 + (repositoryPHID, devicePHID, repositoryVersion, isWriting, 83 + writeProperties) 78 84 VALUES 79 - (%s, %s, %d, %d) 85 + (%s, %s, %d, %d, %s) 80 86 ON DUPLICATE KEY UPDATE 81 - isWriting = VALUES(isWriting)', 87 + isWriting = VALUES(isWriting), 88 + writeProperties = VALUES(writeProperties)', 82 89 $table, 83 90 $repository_phid, 84 91 $device_phid, 85 92 0, 86 - 1); 93 + 1, 94 + phutil_json_encode($write_properties)); 87 95 } 88 96 89 97 ··· 101 109 102 110 queryfx( 103 111 $conn_w, 104 - 'UPDATE %T SET repositoryVersion = %d, isWriting = 0 112 + 'UPDATE %T SET 113 + repositoryVersion = %d, 114 + isWriting = 0, 115 + writeProperties = null 105 116 WHERE 106 117 repositoryPHID = %s AND 107 118 devicePHID = %s AND