diff --git a/src/storage/record_accessor.cpp b/src/storage/record_accessor.cpp index 1400ad1f9..3171f7496 100644 --- a/src/storage/record_accessor.cpp +++ b/src/storage/record_accessor.cpp @@ -200,6 +200,9 @@ template void RecordAccessor::ProcessDelta( const database::StateDelta &delta) const { auto &dba = db_accessor(); + // We need to reconstruct the record as in the meantime some local update + // have updated it. + Reconstruct(); // Apply the delta both on local and remote data. We need to see the changes // we make to remote data, even if it's not applied immediately. auto &updated = update(); diff --git a/tests/unit/distributed_updates.cpp b/tests/unit/distributed_updates.cpp index c4f997b73..62c01e023 100644 --- a/tests/unit/distributed_updates.cpp +++ b/tests/unit/distributed_updates.cpp @@ -128,6 +128,35 @@ TEST_F(DistributedGraphDbTest, CreateVertexWithData) { } } +// Checks if expiring a local record for a local update before applying a remote +// update delta causes a problem +TEST_F(DistributedGraphDbTest, UpdateVertexRemoteAndLocal) { + gid::Gid gid; + storage::Label l1; + storage::Label l2; + { + database::GraphDbAccessor dba{worker(1)}; + auto v = dba.InsertVertex(); + gid = v.gid(); + l1 = dba.Label("label1"); + l2 = dba.Label("label2"); + dba.Commit(); + } + { + database::GraphDbAccessor dba0{master()}; + database::GraphDbAccessor dba1{worker(1), dba0.transaction_id()}; + auto v_local = dba1.FindVertexChecked(gid, false); + auto v_remote = VertexAccessor(storage::VertexAddress(gid, 1), dba0); + + v_remote.add_label(l2); + v_local.add_label(l1); + + auto result = + worker(1).remote_updates_server().Apply(dba0.transaction_id()); + EXPECT_EQ(result, distributed::RemoteUpdateResult::DONE); + } +} + class DistributedEdgeCreateTest : public DistributedGraphDbTest { protected: storage::VertexAddress w1_a;