Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I get this error when trying to use the drush feeds-import from within a module with exec.
The request loops for 105 seconds then fails on two nodes.
Running drush feeds-import manually works as expected.
I'm trying to have a node save kick off a feed import on some other sites with drush aliases.
Comments
Comment #2
nicxvan CreditAttribution: nicxvan as a volunteer commentedLogs from failed import:
Comment #3
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedFeeds doesn't support drush officially yet, it is only available as a patch in #608408: Drush integration for Feeds, which still needs work. There recently was a fix for a timeout, see #2624344: Import via pushImport() keeps looping / never completes. I see you already commented on that issue, so assume you already are using the latest dev?
I haven't investigated the drush patch at all yet, so I'm not sure how I can help you further on this.
Comment #4
kenorb CreditAttribution: kenorb commented#2640498: WD node: PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait [error]
Just increase your timeout limits or improve the Drupal performance in overall.
Comment #5
nicxvan CreditAttribution: nicxvan as a volunteer commentedWhat is the duplicate issue?
Comment #6
kenorb CreditAttribution: kenorb commentedComment #7
kenorb CreditAttribution: kenorb commented...
Comment #8
kenorb CreditAttribution: kenorb commentedThis should be duplicated of #608408: Drush integration for Feeds (as per #3), because the issue is against the patch which wasn't committed yet and it's still under review. So it should be a comment instead (that patch needs work). Or should contribute to the existing patch. Unless it's the same happening in UI (not from CLI), then free to re-open.
Comment #9
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedI have read a bit on what this error means. Source: #2059439: PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction.
So this error means that a database transaction takes too long to complete. In the issue summary is stated that a Feeds import is triggered upon saving a node. I assume you used the hook
hook_node_update()
for this?Database transaction in
node_save()
is open during the whole call of that functionIf you look at the contents of the node_save() function you see that a database transaction is opened at the start of the function. It is closed as soon as the execution of the function ends (the PHP garbage collector will call
DatabaseTransaction::__destruct()
, because the DatabaseTransaction object no longer needs to stay in memory whennode_save()
ends).So when hooks like
hook_node_presave()
,hook_node_insert()
andhook_node_update()
are invoked, thenode_save()
transaction is still open.You can use the Queue API
Running an import with Feeds can take a long time. If it takes longer than say 100 seconds, it is probably a bad idea to run an import right away from within a
hook_node_update()
implementation, because thenode_save()
transaction is still open.Instead, it would be a better idea to queue the operation, so the import would run on cron. You could use the Queue API to create such a queue. The "worker callback" which you define in an implementation of
hook_cron_queue_info()
, would then execute the code you now have in the implementation ofhook_node_update()
. Be sure to pass enough context to the Queue item, but keep the data also as small as possible. It is preferable to not pass a whole node object to a queue, but instead only the node ID. Something like this:Comment #10
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedAs you said you were calling
exec()
, an other solution might be to run that command in the background if you do not need the return value ofexec()
and if there isn't all too much other logic in yourhook_node_update()
implementation.Example:
Source: http://stackoverflow.com/questions/8961470/how-to-make-shell-exec-run-in...
Comment #11
nicxvan CreditAttribution: nicxvan as a volunteer commentedI think I looked at that stack overflow.
I was using hook_entity_update.
I can post the code below, this was for a local install to test.
I never did get it working, I ended up just going with setting the feeds to run hourly.