From: Wolfgang M. M. <wol...@us...> - 2004-07-28 18:55:42
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4115/src/org/exist/xmldb Modified Files: LocalCollection.java LocalXMLResource.java Log Message: * Fixed locking error: a collection object could be unloaded from the cache by one thread, while another thread had still been writing a document being a member of the collection. A moment later, a third thread reloaded the collection and started to write to the same document. However, as the collection had been recreated, there were two instances of the same document in memory. The third thread did thus not respect the lock held by the first thread and started to write without waiting. As a consequence, various page errors were thrown. * When updating a document, the old document metadata had not been correctly removed. Usually, this had no consequences as the collection class only used the last record it found. In some cases however, this may have led to errors. Index: LocalCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalCollection.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** LocalCollection.java 13 Jul 2004 15:13:21 -0000 1.35 --- LocalCollection.java 28 Jul 2004 18:54:53 -0000 1.36 *************** *** 36,39 **** --- 36,40 ---- import org.apache.log4j.Category; + import org.apache.log4j.Logger; import org.exist.EXistException; import org.exist.collections.Collection; *************** *** 68,72 **** public class LocalCollection extends Observable implements CollectionImpl { ! private static Category LOG = Category.getInstance(LocalCollection.class.getName()); protected final static Properties defaultProperties = new Properties(); --- 69,73 ---- public class LocalCollection extends Observable implements CollectionImpl { ! private static Logger LOG = Logger.getLogger(LocalCollection.class.getName()); protected final static Properties defaultProperties = new Properties(); Index: LocalXMLResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalXMLResource.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** LocalXMLResource.java 2 Jul 2004 16:53:53 -0000 1.36 --- LocalXMLResource.java 28 Jul 2004 18:54:53 -0000 1.37 *************** *** 229,233 **** // case 3: content is an internal node or a document } else { - DocumentImpl document = null; try { broker = brokerPool.get(user); --- 229,232 ---- *************** *** 240,256 **** serializer.toSAX((NodeValue) root); else { ! document = getDocument(broker, true); ! if (!document.getPermissions().validate(user, ! Permission.READ)) ! throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, ! "permission denied to read resource"); ! String xml; ! if (id < 0) ! serializer.toSAX(document); ! else { ! if (proxy == null) ! proxy = new NodeProxy(document, id); ! ! serializer.toSAX(proxy); } } --- 239,260 ---- serializer.toSAX((NodeValue) root); else { ! DocumentImpl document = getDocument(broker, true); ! try { ! if (!document.getPermissions().validate(user, ! Permission.READ)) ! throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, ! "permission denied to read resource"); ! String xml; ! if (id < 0) ! serializer.toSAX(document); ! else { ! if (proxy == null) ! proxy = new NodeProxy(document, id); ! ! serializer.toSAX(proxy); ! } ! } finally { ! parent.getCollection().releaseDocument(document); ! brokerPool.release(broker); } } *************** *** 261,267 **** throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e .getMessage(), e); - } finally { - parent.getCollection().releaseDocument(document); - brokerPool.release(broker); } } --- 265,268 ---- *************** *** 407,411 **** protected DocumentImpl getDocument(DBBroker broker, boolean lock) throws XMLDBException { DocumentImpl document = null; ! if(lock) try { document = parent.getCollection().getDocumentWithLock(broker, docId); --- 408,412 ---- protected DocumentImpl getDocument(DBBroker broker, boolean lock) throws XMLDBException { DocumentImpl document = null; ! if(lock) { try { document = parent.getCollection().getDocumentWithLock(broker, docId); *************** *** 414,421 **** "Failed to acquire lock on document " + docId); } ! else document = parent.getCollection().getDocument(broker, docId); ! if (document == null) throw new XMLDBException(ErrorCodes.INVALID_RESOURCE); return document; } --- 415,424 ---- "Failed to acquire lock on document " + docId); } ! } else { document = parent.getCollection().getDocument(broker, docId); ! } ! if (document == null) { throw new XMLDBException(ErrorCodes.INVALID_RESOURCE); + } return document; } |