Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295330

Not possible to save two different nodes at the same time (with two sessions)…

$
0
0

Hello,

I have just started my journey with Drupal 8 and I discovered that it is not possible to save two different nodes at the same time in D8. The explanation seems to be simple (but I am too novice to be sure of it): Every node_save must invalidate a subset of identical tags (aka ‘4xx-response’ and ‘node_list’). As the doPostSave (which will do first the tags invalidation and then other things like calling the hooks hook_xxx_update and hook_xxx_insert) is in the transaction opened by the node save method, if another node has to be saved at the same moment, it will be blocked by the first node being saved (when its tags invalidation will take place).

As I am using hook_node_update to do processing that can be quite heavy, especially for the automated node updates (I am using automated services to synchronise hundreds to thousands of entities provided by external systems), if my users have to compete with these automated services, they could have to wait for quite a long time before being able to save their contributions…

It would be nice to have the doPostSave executed right after the node has been stored in the DB and the transaction has been closed, this could also solve problems like differing the memcache deletes until the doPostSave to avoid race condition in node_save, to invalidate pages in Varnish when the new data is really available, to allow quite heavy processing without blocking other users….

If this is not possible, it would be nice to add some warnings into the documentation of the hook_xxx_update/insert so developers now that, at that moment, they have to consider that the entity is still not stored (as a rollback is still possible if something bad happens in one of the hook_xxx_update/insert implementations) and heavy processes must be differed…

To reproduce this issue:

  • put a breakpoint at line 58 of Drupal\Core\Database\Connection\DatabaseCacheTagsChecksum
  • Save one node and execute the merge
  • From another window, save another node and try to execute the merge. This 'save node' will be blocked until the transaction of the first node is committed

Thanks


Viewing all articles
Browse latest Browse all 295330

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>