8c4e86f48b
Before this change, the queue code would check that none of the fields on the item to be claimed had changed between the time when the item was selected and the item is claimed. While this is a safe approach, it also causes quite a bit of lock contention in MySQL, because InnoDB will take a lock on *any* rows examined by the `where` clause of the `update`, even if they will ultimately thrown out due to other clauses (See: http://dev.mysql.com/doc/refman/5.7/en/innodb-locks-set.html: "A ..., an UPDATE, ... generally set record locks on every index record that is scanned in the processing of the SQL statement. It does not matter whether there are WHERE conditions in the statement that would exclude the row. InnoDB does not remember the exact WHERE condition, but only knows which index ranges were scanned"). As a result, we want to minimize the number of fields accessed in the `where` clause on an update to the QueueItem row. To do so, we introduce a new `state_id` column, which is updated on *every change* to the QueueItem rows with a unique, random value. We can then have the queue item claiming code simply check that the `state_id` column has not changed between the retrieval and claiming steps. This minimizes the number of columns being checked to two (`id` and `state_id`), and thus, should significantly reduce lock contention. Note that we can not (yet) reduce to just a single `state_id` column (which should work in theory), because we need to maintain backwards compatibility with existing items in the QueueItem table, which will be given empty `state_id` values when the migration in this change runs. Also adds a number of tests for other queue operations that we want to make sure operate correctly following this change. [Delivers #133632501] |
||
---|---|---|
.. | ||
data | ||
triggerjson | ||
__init__.py | ||
analytics.py | ||
fulldbtest.sh | ||
helpers.py | ||
queue_threads.py | ||
registry_tests.py | ||
specs.py | ||
test_anon_checked.py | ||
test_api_security.py | ||
test_api_usage.py | ||
test_auth.py | ||
test_backfill_allocator.py | ||
test_blobmodel.py | ||
test_buildman.py | ||
test_cloud_storage.py | ||
test_digest_tools.py | ||
test_dockerfileparse.py | ||
test_endpoints.py | ||
test_endtoend_auth.py | ||
test_external_jwt_authn.py | ||
test_filelike.py | ||
test_gc.py | ||
test_github.py | ||
test_image_sharing.py | ||
test_imagetree.py | ||
test_keystone_auth.py | ||
test_ldap.py | ||
test_license.py | ||
test_manifests.py | ||
test_metricqueue.py | ||
test_morecollections.py | ||
test_names.py | ||
test_notifications.py | ||
test_notificationworker.py | ||
test_permissions.py | ||
test_prepare_trigger.py | ||
test_queries.py | ||
test_queue.py | ||
test_queuefile.py | ||
test_registry_v2_auth.py | ||
test_repomodel.py | ||
test_secscan.py | ||
test_ssl_util.py | ||
test_storageproxy.py | ||
test_storagereplication.py | ||
test_streamlayerformat.py | ||
test_suconfig_api.py | ||
test_swift.py | ||
test_trigger.py | ||
test_util.py | ||
test_v1_endpoint_security.py | ||
test_v2_endpoint_security.py | ||
test_validate_config.py | ||
test_validation.py | ||
test_visible_repos.py | ||
testconfig.py | ||
testlogs.py | ||
testutil.py |