Did you get a JCR error? Add it to the list and provide a resolution if you find one. See also Repository inconsistency.

Symptom

Environment

Cause

Fix

Error when activating nodes:
can't version: update operation failed: failed to write bundle: 1533d777-02e0-4f33-95ab-057e424307bb

Mag 4.4.8 EE

Corrupt versions?

?

ERROR info.magnolia.cms.core.DefaultContent: Failed to get handle: 2dae3093-fde6-488b-bd2f-34785e2c5820: the item does not exist anymore
javax.jcr.InvalidItemStateException: 2dae3093-fde6-488b-bd2f-34785e2c5820: the item does not exist anymore
at org.apache.jackrabbit.core.ItemImpl.sanityCheck(ItemImpl.java:142)
at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1304)

Seen on Mag 4.4.6 CE but could be any version

Corrupt search index

  1. stop Magnolia
  2. go inside your Magnolia web app to repositories/magnolia/workspaces to the workspace folder where you suspect the problem could be (e.g. "data")
  3. delete the index folder in this workspace folder
    Note: Maybe it's a good idea to move the index folder away instead of deleting it. For some reasons sometimes the repository does not start up again if the index folder has been deleted (again with item does not exist errors). Any explanations for this behavior?
  4. startup again

Same error as above

"

Index is fine, but repository is corrupt

Tried configuring the persistence manager with all sorts of check and auto repair flags (1, 2, 3, 4), but nothing helped. Finally I wrote the Groovy script below to remove corrupt ChildNodeEntry records.

What can cause JCR Corruption?

If you have experienced JCR corruption, and can reliably identify the cause, list it here:

Cause

Description

Too many open files.

On linux systems, there is a limit on the number of concurrently open files. When using derby-DB, you have to set this limit high (4096 or more). If you run into the limit during operation, this can cause repo corruption.

OOM exceptions

If your JVM runs out of memory, you can get repository corruption.

JVM crashes

If your JVM segfaults, this can cause the repository to become corrupted, as it is not closed properly and write operations may be interrupted.

This can help other users avoid similar situations in their environment.

Groovy Script to remove invalid child node entries

A JCR node keeps a list of ChildNodeEntries in its State. When you get item does not exist anymore errors and it is not a broken index (see fix above) then chances are, that a node has a ChildNodeEntry with an invalid UUID. The following script walks trough a JCR tree checking the UUID of each ChildNodeEntry removing the ones pointing to nowhere. In order to use it you will need to

  • set the repository
  • and the path to the root know from where on down you would like to examine the tree.
  • Then uncomment the 4 lines once you are sure that it's doing the right thing. (You can let the script run with the two lines commented to see if invalid ChildNodeEntries are found)

Use at your own risk

Script is has been modified before placing it on this page and is therefore untested. Maybe a backup would be a good idea.

Dependency

Currently this script needs the MagnoliaTools installed. Can someone fix this by adding a method to get the current PersistanceManager without the help of external code?

import info.magnolia.context.*;
import info.magnolia.*;
import java.util.*;
import info.magnolia.tools.*;
import org.apache.jackrabbit.core.state.*;

// define the repository:
reponame = "data";
hm = MgnlContext.getSystemContext().getHierarchyManager(reponame);

// configure the root node either by uuid or by path:
//node = hm.getContentByUUID("root_node_uuid");
node = hm.getContent("/path/to/root/node");

jcrNode = node.getJCRNode();
// The PersistenceManagerUtil class is part of the MagnoliaTools. Maybe someone can extend the script so that we don't need the class?
pm = PersistenceManagerUtil.getPM(jcrNode);
checkNode(jcrNode,"");

def checkNode(jcrNode, prefix) {
  println(prefix + jcrNode.getName());
  state = pm.load(jcrNode.getNodeId());
  cl = new ChangeLog();
  childNodeEntries = state.getChildNodeEntries();
  for (childNodeEntry in childNodeEntries) {
    childnode = ContentUtil.getContentByUUID(reponame, childNodeEntry.getId().toString());
    if (childnode == null) {
      println("Subnode missing: " +childNodeEntry.getId().toString());
      // uncomment these lines if you want the corrupt child node entries to be deleted
/*      state.removeChildNodeEntry(childNodeEntry.getId());
      state.setStatus(ItemState.STATUS_STALE_MODIFIED);
      cl.modified(state);
      pm.store(cl);*/
    } else {
      // to visualize the hierarchy:
      checkNode(childnode.getJCRNode(),prefix+"....");
    }
  }
}