* Make sure deleted objects aren't fetched again from database.
Fixes the other half of bug 551 <http://helma.org/bugs/show_bug.cgi?id=551> * Renamed methods in Transactor to make their purpose clearer.
This commit is contained in:
parent
9858091c20
commit
90c02cadc0
3 changed files with 27 additions and 10 deletions
|
@ -285,7 +285,7 @@ public final class Node implements INode, Serializable {
|
||||||
" from two threads at the same time.");
|
" from two threads at the same time.");
|
||||||
}
|
}
|
||||||
|
|
||||||
current.visitNode(this);
|
current.visitDirtyNode(this);
|
||||||
lock = current;
|
lock = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,9 +311,9 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
if (s == CLEAN) {
|
if (s == CLEAN) {
|
||||||
clearWriteLock();
|
clearWriteLock();
|
||||||
tx.dropNode(this);
|
tx.dropDirtyNode(this);
|
||||||
} else {
|
} else {
|
||||||
tx.visitNode(this);
|
tx.visitDirtyNode(this);
|
||||||
|
|
||||||
if (s == NEW) {
|
if (s == NEW) {
|
||||||
clearWriteLock();
|
clearWriteLock();
|
||||||
|
@ -2580,7 +2580,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
// register node with the transactor
|
// register node with the transactor
|
||||||
Transactor current = (Transactor) Thread.currentThread();
|
Transactor current = (Transactor) Thread.currentThread();
|
||||||
current.visitNode(this);
|
current.visitDirtyNode(this);
|
||||||
current.visitCleanNode(this);
|
current.visitCleanNode(this);
|
||||||
|
|
||||||
// recursively make children persistable
|
// recursively make children persistable
|
||||||
|
|
|
@ -165,7 +165,7 @@ public final class NodeManager {
|
||||||
Transactor tx = (Transactor) Thread.currentThread();
|
Transactor tx = (Transactor) Thread.currentThread();
|
||||||
|
|
||||||
// See if Transactor has already come across this node
|
// See if Transactor has already come across this node
|
||||||
Node node = tx.getVisitedNode(key);
|
Node node = tx.getCleanNode(key);
|
||||||
|
|
||||||
if ((node != null) && (node.getState() != Node.INVALID)) {
|
if ((node != null) && (node.getState() != Node.INVALID)) {
|
||||||
return node;
|
return node;
|
||||||
|
@ -232,7 +232,7 @@ public final class NodeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if Transactor has already come across this node
|
// See if Transactor has already come across this node
|
||||||
Node node = tx.getVisitedNode(key);
|
Node node = tx.getCleanNode(key);
|
||||||
|
|
||||||
if ((node != null) && (node.getState() != Node.INVALID)) {
|
if ((node != null) && (node.getState() != Node.INVALID)) {
|
||||||
// we used to refresh the node in the main cache here to avoid the primary key
|
// we used to refresh the node in the main cache here to avoid the primary key
|
||||||
|
@ -277,7 +277,7 @@ public final class NodeManager {
|
||||||
// from the database.
|
// from the database.
|
||||||
node = getNodeByRelation(tx.txn, home, kstr, rel, otherDbm);
|
node = getNodeByRelation(tx.txn, home, kstr, rel, otherDbm);
|
||||||
|
|
||||||
if (node != null) {
|
if (node != null && node.getState() != Node.DELETED) {
|
||||||
Node newNode = node;
|
Node newNode = node;
|
||||||
if (key.equals(node.getKey())) {
|
if (key.equals(node.getKey())) {
|
||||||
node = registerNewNode(node, null);
|
node = registerNewNode(node, null);
|
||||||
|
@ -1856,6 +1856,14 @@ public final class NodeManager {
|
||||||
|
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
|
} else if (Thread.currentThread() instanceof Transactor) {
|
||||||
|
// Check if the node is already registered with the transactor -
|
||||||
|
// it may be in the process of being DELETED.
|
||||||
|
DbKey key = new DbKey(dbmap, id);
|
||||||
|
Node dirtyNode = ((Transactor) Thread.currentThread()).getDirtyNode(key);
|
||||||
|
if (dirtyNode != null) {
|
||||||
|
return dirtyNode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable propMap = new Hashtable();
|
Hashtable propMap = new Hashtable();
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class Transactor extends Thread {
|
||||||
*
|
*
|
||||||
* @param node ...
|
* @param node ...
|
||||||
*/
|
*/
|
||||||
public void visitNode(Node node) {
|
public void visitDirtyNode(Node node) {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
Key key = node.getKey();
|
Key key = node.getKey();
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public class Transactor extends Thread {
|
||||||
*
|
*
|
||||||
* @param node ...
|
* @param node ...
|
||||||
*/
|
*/
|
||||||
public void dropNode(Node node) {
|
public void dropDirtyNode(Node node) {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
Key key = node.getKey();
|
Key key = node.getKey();
|
||||||
|
|
||||||
|
@ -110,6 +110,15 @@ public class Transactor extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a dirty Node from this transaction.
|
||||||
|
* @param key the key
|
||||||
|
* @return the dirty node associated with the key, or null
|
||||||
|
*/
|
||||||
|
public Node getDirtyNode(Key key) {
|
||||||
|
return (Node) dirtyNodes.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep a reference to an unmodified Node local to this transaction
|
* Keep a reference to an unmodified Node local to this transaction
|
||||||
*
|
*
|
||||||
|
@ -154,7 +163,7 @@ public class Transactor extends Thread {
|
||||||
*
|
*
|
||||||
* @return ...
|
* @return ...
|
||||||
*/
|
*/
|
||||||
public Node getVisitedNode(Object key) {
|
public Node getCleanNode(Object key) {
|
||||||
return (key == null) ? null : (Node) cleanNodes.get(key);
|
return (key == null) ? null : (Node) cleanNodes.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue