Problem/Motivation

I used the module on a site that uses the memcache module, to convert some nodes from bundle A to bundle B. After the process finished, although all the revisions of the node (both on base tables, and on field tables) got converted to B, when the new revision got saved, it got saved again as bundle A. Also in the log message of this revision there was written "Converted from A to A."

I have noticed also other cache problems, not related to convert_bundles, which I haven't yet debugged, clearly memcache has some issues on cache invalidation.

I see that addNewFields calls drupal_flush_all_caches() in the beginning, which should be enough when the entity is loaded later. But because of the insufficient cache invalidation on memcache, the entity gets loaded on its old status, so it gets loaded as bundle A, and the new revision is created and saved again as bundle A.

Steps to reproduce

The description should be enough to explain how to reproduce, but there is a problem: The bug is random. It doesn't happen every time.
It never happens when the default db cache is used.
It definitely has to do with using external systems (like memcache) for caching. It might have to do with bugs on the memcache module, or the memcache library, or the memcache extension, or the memcached itself, or it could also be a generic issue when external caching systems are used.

Proposed resolution

I have an open question whether calling drupal_flush_all_caches() at the beginning is too hard and should be removed, but this is irrelevant here. Let's keep it as it is for now.

But I propose to use the core's resetCache function, as an extra step before loading the entity in the addNewFields operation. That way, even if the flushing of caches did not complete successfully (which, of course, is NOT convert_bundle's responsibility), at least we instruct the core to load the entity completely uncached, directly from the database, which is anyway the intention.

Remaining tasks

Review.

User interface changes

-

API changes

-

Data model changes

-

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

efpapado created an issue. See original summary.

efpapado’s picture

Issue summary: View changes

efpapado’s picture

Issue summary: View changes
Status: Active » Needs review

MR created.

efpapado changed the visibility of the branch 3518109-the-new-revision to hidden.

anybody’s picture

Thanks @efpapado totally makes sense to me code-wise. Let's see what the maintainers think.

joseph.olstad’s picture

Version: 2.0.x-dev » 3.0.x-dev
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.