Problem/Motivation

For databases with a large number of node revisions, node_update_7005() is prone to PHP timeout errors.

Proposed resolution

Use the batch processing system in node_update_7005() to only process one column at a time.

Remaining tasks

Commit patch.

User interface changes

None.

API changes

None.

Original report by @fractile81

I consistently have a timeout when I try to update my D6 database to D7. My node_revision(s) table has over 388400 entries in it and node_update_7005(); appears to be choking on that. I checked the system table and verified that node was on schema_version 7004 after the timeout.

When I do a describe node_revision, it has all but the 'sticky' column added. I tried adding it manually to my database and it ran for 19.2 seconds. Multiply that by four, and I can see why this update might be causing my problems.

Possible fixes that come to mind are to turn it into a batch or extend the execution timeout for the page (or both?).

Comments

fractile81’s picture

Status: Active » Needs review
StatusFileSize
new1022 bytes

Attached is a patch that converts this update to use batching. This fixed my problem.

Status: Needs review » Needs work

The last submitted patch, node_update_7005_fix.patch, failed testing.

fractile81’s picture

Status: Needs work » Needs review
StatusFileSize
new1.16 KB

Trying the patch again...

Status: Needs review » Needs work

The last submitted patch, node_update_7005_fix.patch, failed testing.

fractile81’s picture

Status: Needs work » Needs review
StatusFileSize
new1012 bytes

Last try, then I'll just let someone else figure out why the patch doesn't work. The actual change should work, though.

fractile81’s picture

StatusFileSize
new981 bytes

And now I just feel sheepish... UNIX-style EOL now!

fractile81’s picture

Version: 7.0-beta2 » 7.x-dev
Component: node system » update system

Correcting the metadata.

thedavidmeister’s picture

Component: update system » ajax system
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

Without any actual data to test with that would likely timeout, it's a bit hard to manually test this.

Code makes sense to me though upon an inspection.

My only criticism is that there should be a newline separating the two lines in the docbloc comment.

Also, patch needs a reroll:

tdm:d7 thedavidmeister$ git apply node_update_7005_fix_2.patch 
fatal: patch fragment without header at line 3: @@ -534,14 +534,24 @@
gaurav.goyal’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new1 KB

Patch is rerolled according to current codebase, so removing Needs reroll tag.

Status: Needs review » Needs work

The last submitted patch, 9: 968288_node_update_7005_fix.patch, failed testing.

gaurav.goyal’s picture

Status: Needs work » Needs review
StatusFileSize
new1019 bytes

Corrected if condition, resubmitting the patch.

thedavidmeister’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1013 bytes

There was a slight whitespace error in that patch. I fixed it up here, but it's so minor I'm setting RTBC.

thedavidmeister’s picture

Status: Reviewed & tested by the community » Needs review
thedavidmeister’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: 968288-12.patch, failed testing.

David_Rothstein’s picture

Status: Needs work » Needs review

12: 968288-12.patch queued for re-testing.

David_Rothstein’s picture

Component: ajax system » database update system
Priority: Normal » Major
Issue tags: +D7 upgrade path

Crazy that this is necessary, but if it is that makes it major.

Shouldn't $sandbox['#finished'] be set to a fraction between 0 and 1 after each stage (so the progress bar is more realistic)? That's normally how it's done, and in fact setting to 1 at the end shouldn't even be necessary. See taxonomy_update_7011() for an example.

thedavidmeister’s picture

Status: Needs review » Needs work

Yes, technically you should set #finished to a number between 0 and 1 and it is not necessary to set it at all in the case that you want the loop to end. Funny, I updated the docs for that less than a month ago and totally missed this :( #2141221: hook_update_N() should document how to use $sandbox['#finished'].

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.