mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
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
This commit is contained in:
parent
f24ae96bb6
commit
7d9bda59a6
1 changed files with 14 additions and 1 deletions
|
@ -240,10 +240,23 @@ final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery {
|
|||
private function getLeaseOwnershipName() {
|
||||
static $sequence = 0;
|
||||
|
||||
// TODO: If the host name is very long, this can overflow the 64-character
|
||||
// column, so we pick just the first part of the host name. It might be
|
||||
// useful to just use a random hash as the identifier instead and put the
|
||||
// pid / time / host (which are somewhat useful diagnostically) elsewhere.
|
||||
// Likely, we could store a daemon ID instead and use that to identify
|
||||
// when and where code executed. See T6742.
|
||||
|
||||
$host = php_uname('n');
|
||||
$host = id(new PhutilUTF8StringTruncator())
|
||||
->setMaximumBytes(32)
|
||||
->setTerminator('...')
|
||||
->truncateString($host);
|
||||
|
||||
$parts = array(
|
||||
getmypid(),
|
||||
time(),
|
||||
php_uname('n'),
|
||||
$host,
|
||||
++$sequence,
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue