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

Prevent worker queue leases from exceeding 64 characters

Summary:
Ref T6742. Root cause of the issue:

- Daemon was running on a machine with a very long host name, which produced a lease name which was longer than 64 characters.
- MySQL wasn't set in STRICT_ALL_TABLES.
- The daemon would `UPDATE .. SET leaseOwner = <very long string>` to lock a task, and MySQL would silently truncate.
- The daemon would then try to select the locked task, but fail, because there's no matching lease owner.

To resolve this, use only the first 32 characters of the hostname. See IRC for more discussion.

Test Plan: Will confirm with reporter.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6742

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

+14 -1
+14 -1
src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php
··· 240 240 private function getLeaseOwnershipName() { 241 241 static $sequence = 0; 242 242 243 + // TODO: If the host name is very long, this can overflow the 64-character 244 + // column, so we pick just the first part of the host name. It might be 245 + // useful to just use a random hash as the identifier instead and put the 246 + // pid / time / host (which are somewhat useful diagnostically) elsewhere. 247 + // Likely, we could store a daemon ID instead and use that to identify 248 + // when and where code executed. See T6742. 249 + 250 + $host = php_uname('n'); 251 + $host = id(new PhutilUTF8StringTruncator()) 252 + ->setMaximumBytes(32) 253 + ->setTerminator('...') 254 + ->truncateString($host); 255 + 243 256 $parts = array( 244 257 getmypid(), 245 258 time(), 246 - php_uname('n'), 259 + $host, 247 260 ++$sequence, 248 261 ); 249 262