Page MenuHomePhabricator

`./bin/config set --database` does not handle deleted keys
Closed, ResolvedPublic

Description

When config key is marked as deleted in database ./bin/config set --database key value does not update isDeleted column and is essentially a no-op.

Steps to reproduce:

$ ./bin/config --trace set --database phabricator.timezone GMT
>>> [2] <query> SELECT * FROM `config_entry` WHERE configKey = 'phabricator.timezone' AND namespace = 'default'
<<< [2] <query> 6,037 us
>>> [3] <connect> phabricator_config
<<< [3] <connect> 1,143 us
>>> [4] <query> INSERT INTO `config_entry` (`namespace`, `configKey`, `value`, `isDeleted`, `phid`, `dateCreated`, `dateModified`) VALUES ('default', 'phabricator.timezone', '\"GMT\"', '0', 'PHID-CONF-gas3xqe5nqyexsp5stwp', '1489686019', '1489686019')
<<< [4] <query> 23,092 us
Set 'phabricator.timezone' in database configuration.

All good. Key did not exist, new is inserted.

$ ./bin/config --trace delete --database phabricator.timezone
>>> [2] <query> SELECT * FROM `config_entry` WHERE namespace = 'default' AND isDeleted = 0
<<< [2] <query> 6,294 us
>>> [3] <query> SELECT * FROM `config_entry` WHERE configKey = 'phabricator.timezone' AND namespace = 'default'
<<< [3] <query> 463 us
>>> [4] <connect> phabricator_config
<<< [4] <connect> 1,060 us
>>> [5] <query> UPDATE `config_entry` SET `namespace` = 'default', `configKey` = 'phabricator.timezone', `value` = '\"GMT\"', `isDeleted` = '1', `id` = '1', `phid` = 'PHID-CONF-gas3xqe5nqyexsp5stwp', `dateCreated` = '1489686019', `dateModified` = '1489686030' WHERE `id` = '1'
<<< [5] <query> 25,269 us
Deleted 'phabricator.timezone' from database configuration.

All good. Key deleted.

$ ./bin/config --trace set --database phabricator.timezone UTC
>>> [2] <query> SELECT * FROM `config_entry` WHERE configKey = 'phabricator.timezone' AND namespace = 'default'
<<< [2] <query> 6,203 us
>>> [3] <connect> phabricator_config
<<< [3] <connect> 1,156 us
>>> [4] <query> UPDATE `config_entry` SET `namespace` = 'default', `configKey` = 'phabricator.timezone', `value` = '\"UTC\"', `isDeleted` = '1', `id` = '1', `phid` = 'PHID-CONF-gas3xqe5nqyexsp5stwp', `dateCreated` = '1489686019', `dateModified` = '1489686042' WHERE `id` = '1'
<<< [4] <query> 22,892 us
Set 'phabricator.timezone' in database configuration.

Oops! value updated but isDeleted still 1.

$ ./bin/config --trace get phabricator.timezone
>>> [2] <query> SELECT * FROM `config_entry` WHERE namespace = 'default' AND isDeleted = 0
<<< [2] <query> 5,655 us
{
  "config": [
    {
      "key": "phabricator.timezone",
      "source": "local",
      "value": null,
      "status": "unset",
      "errorInfo": null
    },
    {
      "key": "phabricator.timezone",
      "source": "database",
      "value": null,
      "status": "unset",
      "errorInfo": null
    }
  ]
}

Expected to get new value ("UTC") from database but got null.


Version Information:
phabricator 19af10df37063230e219a95b4d773c70f2ea3ce0 (Thu, Mar 16)
arcanist 3b6b523c2b236e3724a1e115f126cb6fd05fa128 (Sat, Feb 18)
phutil 13a200ca7621ab2b48a0c395f52f8c4411bbc686 (Sat, Mar 4)