xxxxxx
delete FROM sources WHERE (id not IN (SELECT source_id FROM logs ));
xxxxxx
This query makes a lot of SELECTS in "Locked" State.
mysql> show processlist;
···
*+----+--------+-----------+--------+---------+------+--------------+------------------------------------------------------------------------------------------------------+*
*| Id | User | Host | db | Command | Time | State | Info
>*
±—±-------±----------±-------±--------±-----±-------------±-----------------------------------------------------------------------------------------------------+ | 1 | puppet | localhost | puppet | Query | 2 | Locked |
SELECT sources. FROM sources WHERE sources.digest =
'5079ac11c59ac57c3c7d93bb859fdfa8add5 |* | 6 | puppet | localhost | puppet | Query | 9 | Locked |
SELECT sources. FROM sources WHERE sources.digest =
'e2077b72593164b9fb6046c741df3272e78d |* | 13 | puppet | localhost | puppet | Query | 8 | Locked |
SELECT sources. FROM sources WHERE sources.digest =
'30967a4757fbf5342258101cea83ab29b573 |* | 31 | root | localhost | NULL | Query | 0 | NULL | show
processlist
> | 32 | puppet | localhost | puppet | Query | 16 | Sending data |
DELETE FROM sources WHERE (id not IN (SELECT source_id FROM logs ))
> ±—±-------±----------±-------±--------±-----±-------------±-----------------------------------------------------------------------------------------------------+ 5 rows in set (0.00 sec)
*mysql> *
I add an index to the logs table and now is working much better
···
On 17/02/15 15:57, Santi Nuñez-Cacho wrote:
> Hi,
>
> When migrating to 1.7 I came across with this.
>
> Executing reports i see this in the processlist mysql show:
>
>
> # RAILS_ENV=production rake -s -f /usr/share/foreman/Rakefile
> reports:expire days=7
> .....
> ..
>
>
> > show processlist:
>
> xxxxxx
> delete FROM `sources` WHERE (id not IN (SELECT source_id FROM `logs` ));
> xxxxxx
I did the ~ 1.1 (don't recall specific version but was around there) to
1.7.3. Was experiencing same issue with locked tables and Foreman failing
to respond to ENC requests during the reports:expire run.
My mysql processlist shows the changes from #8565 present, but did not
correct the issue.
···
> show processlist;
+----+--------+-----------+--------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
> Id | User | Host | db | Command | Time | State
> Info
>
+----+--------+-----------+--------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
> 1 | puppet | localhost | puppet | Query | 307 | Locked
> SELECT `sources`.* FROM `sources` WHERE `sources`.`digest` =
'a100926532eb335a499d37a6bdb525c0d49e |
> 3 | puppet | localhost | puppet | Query | 17 | Locked
> SELECT `sources`.* FROM `sources` WHERE `sources`.`digest` =
'298db879914a8cf0b602f3235864a495b741 |
> 4 | puppet | localhost | puppet | Query | 20 | Locked
> SELECT `sources`.* FROM `sources` WHERE `sources`.`id` IN (192)
>
> 5 | root | localhost | puppet | Query | 0 | NULL
> show processlist
>
> 6 | puppet | localhost | puppet | Query | 311 | Copying to tmp table
> DELETE FROM `sources` WHERE (id not IN (SELECT DISTINCT source_id FROM
`logs` )) |
> 7 | puppet | localhost | puppet | Query | 280 | Locked
> SELECT `sources`.* FROM `sources` WHERE `sources`.`digest` =
'a100926532eb335a499d37a6bdb525c0d49e |
> 8 | puppet | localhost | puppet | Query | 283 | Locked
> SELECT `sources`.* FROM `sources` WHERE `sources`.`digest` =
'a100926532eb335a499d37a6bdb525c0d49e |
> 9 | puppet | localhost | puppet | Query | 193 | Locked
> SELECT `sources`.* FROM `sources` WHERE `sources`.`id` IN (192)
>
+----+--------+-----------+--------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
8 rows in set (0.00 sec)
Running the following did fix it:
ALTER TABLE logs ADD INDEX index_logs_on_source_id (source_id)
Reports::expire runs much much faster (in seconds rather than 10 - 15
minutes) and Foreman doesn’t lock up while it’s running.
On Wednesday, February 18, 2015 at 3:11:48 AM UTC-5, Dominic Cleal wrote:
On 17/02/15 15:57, Santi Nuñez-Cacho wrote:
Hi,
When migrating to 1.7 I came across with this.
Executing reports i see this in the processlist mysql show: