KleppmannTree: fix failed moves being recorded in op log

This commit is contained in:
2025-03-22 14:57:01 +01:00
parent 16eb1d28d9
commit dc0e73b1aa
2 changed files with 12 additions and 2 deletions

View File

@@ -167,8 +167,8 @@ public class KleppmannTree<TimestampT extends Comparable<TimestampT>, PeerIdT ex
public void move(NodeIdT newParent, MetaT newMeta, NodeIdT child, boolean failCreatingIfExists) {
var createdMove = createMove(newParent, newMeta, child);
_opRecorder.recordOp(createdMove);
applyOp(_peers.getSelfId(), createdMove, failCreatingIfExists);
_opRecorder.recordOp(createdMove);
}
public void applyExternalOp(PeerIdT from, OpMove<TimestampT, PeerIdT, MetaT, NodeIdT> op) {

View File

@@ -96,7 +96,7 @@ public class KleppmanTreeSimpleTest {
void undoWithRenameTest(boolean opOrder) {
var d1id = testNode1._storageInterface.getNewNodeId();
var d2id = testNode2._storageInterface.getNewNodeId();
var d3id = testNode2._storageInterface.getNewNodeId();
var d3id = testNode3._storageInterface.getNewNodeId();
testNode1._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d1id);
testNode2._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d2id);
testNode3._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d3id);
@@ -137,4 +137,14 @@ public class KleppmanTreeSimpleTest {
Assertions.assertIterableEquals(List.of("Test1", "Test1.conflict." + d1id, "Test1.conflict." + d2id), testNode3._storageInterface.getById(testNode3._storageInterface.getRootId()).children().keySet());
}
@Test
void noFailedOpRecordTest() {
var d1id = testNode1._storageInterface.getNewNodeId();
var d2id = testNode1._storageInterface.getNewNodeId();
testNode1._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d1id);
Assertions.assertThrows(AlreadyExistsException.class, () -> testNode1._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d2id));
var r1 = testNode1.getRecorded();
Assertions.assertEquals(1, r1.size());
}
}