Skip to content

Commit

Permalink
Log new object versions immediately after creation (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
senderista authored Oct 12, 2021
1 parent 108f8a2 commit 52f619c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
13 changes: 6 additions & 7 deletions production/db/core/src/gaia_ptr_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,16 +425,16 @@ gaia_ptr_t gaia_ptr_t::create(gaia_id_t id, gaia_type_t type, reference_offset_t
ASSERT_INVARIANT(data_size == 0, "Null payload with non-zero payload size!");
}

WRITE_PROTECT(obj.to_offset());
client_t::txn_log(locator, c_invalid_gaia_offset, obj.to_offset(), gaia_operation_t::create);

auto_connect_to_parent(
id,
type,
// NOLINTNEXTLINE: cppcoreguidelines-pro-type-const-cast
const_cast<gaia_id_t*>(obj_ptr->references()),
reinterpret_cast<const uint8_t*>(obj_ptr->data()));

WRITE_PROTECT(locator_to_offset(locator));
client_t::txn_log(locator, c_invalid_gaia_offset, obj.to_offset(), gaia_operation_t::create);

obj.create_insert_trigger(type, id);
return obj;
}
Expand Down Expand Up @@ -600,6 +600,9 @@ gaia_ptr_t& gaia_ptr_t::update_payload(size_t data_size, const void* data)
new_this->num_references = old_this->num_references;
memcpy(new_this->payload + references_size, data, data_size);

WRITE_PROTECT(to_offset());
client_t::txn_log(m_locator, old_offset, to_offset(), gaia_operation_t::update);

auto new_data = reinterpret_cast<const uint8_t*>(data);
auto old_data = reinterpret_cast<const uint8_t*>(old_this->payload);
const uint8_t* old_data_payload = old_data + references_size;
Expand All @@ -613,10 +616,6 @@ gaia_ptr_t& gaia_ptr_t::update_payload(size_t data_size, const void* data)
new_data,
changed_fields);

WRITE_PROTECT(to_offset());

client_t::txn_log(m_locator, old_offset, to_offset(), gaia_operation_t::update);

if (client_t::is_valid_event(new_this->type))
{
client_t::s_events.emplace_back(event_type_t::row_update, new_this->type, new_this->id, changed_fields, get_txn_id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ TEST_F(test_connect_disconnect, test_disconnect_1_1)
gaia::db::commit_transaction();
}

// Temporarily disabled until https://gaiaplatform.atlassian.net/browse/GAIAPLAT-1501 is resolved.
TEST_F(test_connect_disconnect, DISABLED_disconnect_delete)
TEST_F(test_connect_disconnect, disconnect_delete)
{
gaia::rules::subscribe_ruleset("test_disconnect_delete");

Expand Down

0 comments on commit 52f619c

Please sign in to comment.