I'm getting hundreds of these in my slow query log, and I'm not sure why.

# Query_time: 0 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
DELETE FROM semaphore WHERE value = '16810499904bf043683336e8.58613630';

Each one has a different value, and the table is indexed on the expire element the way it should be. These do not appear if I disable logging of queries that could not use an index, but there's hundreds of them if I enable it.

Any ideas?

Comments

damien tournoud’s picture

Title: Hundreds of slow queries in log per minute » No index on {semaphore}.value
Version: 6.16 » 7.x-dev
Component: cron system » base system
Category: support » bug

Oh. We don't have an index on {semaphore}.value... that's a weird oversight.

Requalifying as a bug and bumping to D7.

dawehner’s picture

Drupal7


  $schema['semaphore'] = array(
    'description' => 'Table for holding semaphores, locks, flags, etc. that cannot be stored as Drupal variables since they must not be cached.',
    'fields' => array(
      'name' => array(
        'description' => 'Primary Key: Unique name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => ''
      ),
      'value' => array(
        'description' => 'A value for the semaphore.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => ''
      ),
      'expire' => array(
        'description' => 'A Unix timestamp with microseconds indicating when the semaphore should expire.',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE
      ),
    ),
    'indexes' => array('value' => array('value')),
    'primary key' => array('name'),
  );

Drupal6


  $schema['semaphore'] = array(
    'description' => 'Table for holding semaphores, locks, flags, etc. that cannot be stored as Drupal variables since they must not be cached.',
    'fields' => array(
      'name' => array(
        'description' => 'Primary Key: Unique name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => ''),
      'value' => array(
        'description' => 'A value.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => ''),
      'expire' => array(
        'description' => 'A Unix timestamp with microseconds indicating when the semaphore should expire.',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE),
      ),
    'indexes' => array('expire' => array('expire')),
    'primary key' => array('name'),
    );

I think we would have to add expire to d7 and value to d6, right?

marcingy’s picture

Status: Active » Needs review
StatusFileSize
new620 bytes

Adding expire index to d7.

Status: Needs review » Needs work

The last submitted patch, semaphore-missing-index.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review

Hmmm

marcingy’s picture

#3: semaphore-missing-index.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, semaphore-missing-index.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

#3: semaphore-missing-index.patch queued for re-testing.

damien tournoud’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Bumping to major, and I am happy with #3.

dries’s picture

Project: Drupal core » HEAD to HEAD
Version: 7.x-dev »
Component: base system » Code
Status: Reviewed & tested by the community » Needs work

Committed to CVS HEAD. Moving this to the HEAD to HEAD project.

rfay’s picture

Project: HEAD to HEAD » Drupal core
Version: » 6.x-dev
Component: Code » base system
Status: Needs work » Patch (to be ported)

This needs to go to Drupal 6.

Please create new issues for head2head.

I created #863662: Add index on {semaphore}.expire

damien tournoud’s picture

Yes, please stop moving core issues to HEAD2HEAD and create new issues instead. That makes things impossible to follow.

gábor hojtsy’s picture

I'm not so sure that this actually needs to be a head2head issue, since we do generally support updates from whatever previous Drupal version, so the update function will need to be ported to D7 as well and committed here.

albert volkman’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new844 bytes

D6 backport.

mgifford’s picture

Patch in #14 applies nicely to D6. I just stumbled upon this when looking through my slow query logs.

This is probably RTBC.

mgifford’s picture

Status: Needs review » Needs work

The last submitted patch, 14: semaphore_value_index-800432-d6-14.patch, failed testing.

mgifford’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

I think we can safely mark this as won't fix given this stage of D6's life cycle.

pwolanin’s picture

Status: Closed (won't fix) » Needs work

We are seeing this with Drupal 6 - no harm in at least having a working patch

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new845 bytes

Here's a re-roll. Something changed in the code comment at the end of the file that was causing the patch to not apply.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.