Problem/Motivation

Redirect module's access logging feature requires a database write for each request. This can be a performance bottleneck for high-traffic sites.

Proposed resolution

If we make this feature optional, then site admins will have the option of handling redirects without any database writes.

Create a redirect_access submodule that is optional. Let it maintain a redirect_access table with rid, timestamp, uid, hostname columns.
Drop expiration handling feature from base module and move into the submodule.

Remaining tasks

Do so for D7 and D8.

User interface changes

API changes

Data model changes

Comments

mfb’s picture

Status: Active » Needs review
StatusFileSize
new4.06 KB

Here's a patch adding two new settings, for disabling access logging and loop detection.

This patch also fixes what appears to be a bug in redirect_purge_inactive_redirects() - it does not purge inactive redirects if redirect_page_cache is disabled.

fenstrat’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)

Making the database writes optional is a good idea, however removing them all together is a better option. Marking as a duplicate of #1263832: Remove session-based flood / loop detection since it performs poorly, and has unfixable race conditions

mfb’s picture

Status: Closed (duplicate) » Needs review

Disabling the access logging could still be useful for sites that don't need it or want to disable it when the database is under heavy load.

fenstrat’s picture

I'm confused @mfb, in #1263832: Remove session-based flood / loop detection since it performs poorly, and has unfixable race conditions you argue for the removal of this. Should we change back to this issue and make it optional?

mfb’s picture

This issue is about making two things optional: loop detection and access logging.

The other issue is only about loop detection.

fenstrat’s picture

Right ok. So given there consensus in #1263832: Remove session-based flood / loop detection since it performs poorly, and has unfixable race conditions to remove loop detection can this issue be refocused on only making redirect logging optional?

dave reid’s picture

Status: Needs review » Needs work

Yes, this should definitely be refocused.

mfb’s picture

Issue summary: View changes
StatusFileSize
new2.52 KB

Ok rerolled the patch.

mfb’s picture

Status: Needs work » Needs review
pere orga’s picture

Status: Needs review » Needs work

I think that everytime a new variable is used, we should add it to the redirect_variables() function.

mfb’s picture

Status: Needs work » Needs review
StatusFileSize
new2.73 KB

added to redirect_variables()

pere orga’s picture

Status: Needs review » Reviewed & tested by the community

It works, thanks

dave reid’s picture

Status: Reviewed & tested by the community » Needs work

I think this could be made a bit more clear 'access log' of redirects doesn't really match what is happening. I would prefer this is exposed in the UI more like the core statistics module counter. Something more like 'Count redirects'

mfb’s picture

Status: Needs work » Needs review
StatusFileSize
new2.82 KB

Ok renamed the variable to Count redirects

Status: Needs review » Needs work

The last submitted patch, 14: redirect-2119157-new-config-count.patch, failed testing.

mfb’s picture

Status: Needs work » Needs review
StatusFileSize
new2.82 KB

rerolled

dave reid’s picture

dave reid’s picture

Assigned: Unassigned » dave reid

I'm actually going to take this in a separate direction. I'd rather have a separate module for handling the logging and expiration of unused redirects.

miro_dietiker’s picture

Issue tags: +8.x release target

Much agree that supporting deletion of unused redirects should not add complexity to the basic module.

I'm still much interested in when a redirect was created and it it was used ever.
Adding a create timestamp is still subject for redirect core functionality: #1853144: Store created date/time
How about the access timestamp then?

dave reid’s picture

access timestamp should still be in a separate table and not available from an entity_load() of a redirect. I was thinking a redirect_access table with rid, timestamp, uid, hostname columns for when a redirect is "logged."

miro_dietiker’s picture

Agree this is a proper approach. Are we rescoping this issue to include the redirect_access table (or stay with expiring topic only and split that log rewrite into a separate issue)?

dave reid’s picture

I was planning on using this issue to add the new redirect_access submodule to the 7.x-1.x codebase for 1.0 release.

miro_dietiker’s picture

Issue summary: View changes

Updated the issue summary.

miro_dietiker’s picture

This rework makes it related to....

berdir’s picture

Issue tags: -8.x release target

This feature has been completely removed from the 8.x-1.x port, at least for now.

With caching of redirects enabled by default (and reliably, thanks to cache tags), it was no longer possible to rely on it.

dave reid’s picture

I've decided I can't change something major like this in the 1.x branch, so I'll be opening a 2.x branch shortly for this new sub-module.

dave reid’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
socialnicheguru’s picture

doesn't seem to apply anymore

chris matthews’s picture

Status: Needs review » Needs work

I've decided I can't change something major like this in the 1.x branch, so I'll be opening a 2.x branch shortly for this new sub-module.

The latest patch in #17 does not apply to the latest 7.x-2.x-dev.

Checking patch redirect.admin.inc...
error: while searching for:
    '#default_value' => variable_get('redirect_purge_inactive', 0),
    '#options' => array(0 => t('Never (do not discard)')) + drupal_map_assoc(array(604800, 1209600, 1814400, 2592000, 5184000, 7776000, 10368000, 15552000, 31536000), 'format_interval'),
    '#description' => t('Only redirects managed by the redirect module itself will be deleted. Redirects managed by other modules will be left alone.'),
    '#disabled' => variable_get('redirect_page_cache', 0) && !variable_get('page_cache_invoke_hooks', TRUE),
  );

  $form['globals'] = array(

error: patch failed: redirect.admin.inc:634
error: redirect.admin.inc: patch does not apply
Checking patch redirect.module...
Hunk #1 succeeded at 345 (offset 1 line).
error: while searching for:
    $interval = variable_get('redirect_purge_inactive', 0);
  }

  if (!$interval || !variable_get('redirect_page_cache', 0) || !variable_get('page_cache_invoke_hooks', TRUE)) {
    // If serving redirects from the page cache is enabled and hooks are not
    // executed during page caching, then we cannot track when a redirect is
    // used. Therefore, we cannot remove unused redirects.

error: patch failed: redirect.module:935
error: redirect.module: patch does not apply
mfb’s picture

Status: Needs work » Needs review
StatusFileSize
new2.79 KB

Rerolled.

mfb’s picture

It looks like 7.x-2.x and 7.x-1.x branches are the same.

Personally, I think this patch should be fine to apply on both branches. It's just adding an extra config that allows sites to reduce database writes (and in the process, disable a feature) if they want to. It's not a breaking change as far as I can tell.

I also think that re-architecting this and other things makes sense in 7.x-2.x branch, but that hasn't happened yet. In the meantime, it's useful to roll this out to existing sites now rather than waiting for 7.x-2.x to diverge and stabilize.

chris matthews’s picture

Assigned: dave reid » Unassigned

@mfb, thank you. The rerolled patch in #31 to redirect.admin.inc and redirect.module does apply cleanly to both 7.x-1.x-dev and 7.x-2.x-dev. I agree with your comments, but I'll leave the issue metadata as it is for now so that someone else more experienced than myself to update as necessary.