This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data
Joseph Schorr 8c4e86f48b Change queue to use state-field for claiming items
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]
2017-01-17 13:29:26 -05:00
..
interfaces Fix issue in V1 registry code with accessing locations under HEAD 2016-10-03 17:09:12 +03:00
migrations Change queue to use state-field for claiming items 2017-01-17 13:29:26 -05:00
model Make sure robot accounts always show up first in entity search 2016-12-16 15:04:30 -05:00
users Add default and configurable LDAP timeouts 2016-12-19 11:53:06 -05:00
__init__.py Refactor the code into modules, it was getting unweildy. 2013-09-25 12:45:12 -04:00
archivedlogs.py userfiles: make handler optional 2016-04-15 13:56:07 -04:00
billing.py Add even larger plans for enterprises on SaaS 2016-03-21 16:38:34 -04:00
buildlogs.py Change the append build log method to execute the two calls via one pipelined connection 2016-11-18 11:47:16 -05:00
database.py Change queue to use state-field for claiming items 2017-01-17 13:29:26 -05:00
fields.py Fix torrent hash generation to work in mixed stacks 2016-01-11 16:43:46 -05:00
queue.py Change queue to use state-field for claiming items 2017-01-17 13:29:26 -05:00
read_slave.py Add support for read slave databases. 2014-07-02 19:10:24 -04:00
runmigration.py Implement new step-by-step setup 2015-01-23 17:19:15 -05:00
userevent.py Handle user events Redis not working in tutorial 2016-06-28 17:04:31 -04:00
userfiles.py userfiles: make handler optional 2016-04-15 13:56:07 -04:00