Tests and fix remote update already deleted bug
Summary: Updating a record locally while there is an remote update waiting to be applied caused the operation to return as already deleted, instead of applying it Reviewers: florijan Reviewed By: florijan Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1226
This commit is contained in:
parent
017e8004e8
commit
753aa07cdf
@ -200,6 +200,9 @@ template <typename TRecord>
|
||||
void RecordAccessor<TRecord>::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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user