Fix PrepareForWrite function in storage V2

Summary:
We forgot to update `modified_vertices` in the case when the vertex
has an empty version chain. It didn't manifest before because it was impossible
for a vertex to have an empty version chain without garbage collection.

Reviewers: mferencevic, teon.banek

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2154
This commit is contained in:
Marin Tomic 2019-07-01 10:52:11 +02:00
parent f2b23828ab
commit a7fabe6109

View File

@ -52,12 +52,18 @@ inline void ApplyDeltasForRead(Transaction *transaction, Delta *delta,
/// transaction) and returns a `bool` value indicating whether the caller can
/// proceed with a write operation.
inline bool PrepareForWrite(Transaction *transaction, Vertex *vertex) {
if (vertex->delta == nullptr) return true;
if (vertex->delta == nullptr) {
if (transaction->modified_vertices.empty() ||
transaction->modified_vertices.back() != vertex) {
transaction->modified_vertices.push_back(vertex);
}
return true;
}
auto ts = vertex->delta->timestamp->load(std::memory_order_acquire);
if (ts == transaction->transaction_id || ts < transaction->start_timestamp) {
auto it = transaction->modified_vertices.rbegin();
if (it == transaction->modified_vertices.rend() || *it != vertex) {
if (transaction->modified_vertices.empty() ||
transaction->modified_vertices.back() != vertex) {
transaction->modified_vertices.push_back(vertex);
}
return true;