Fix primitive host clang-tidy findings
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (client) (push) Successful in 12m16s
Foundation / checks (network) (push) Successful in 13m43s
Foundation / checks (tsan) (push) Successful in 8m11s
Foundation / checks (postgres) (push) Failing after 20m58s
Foundation / checks (checks) (push) Successful in 33m53s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (client) (push) Successful in 12m16s
Foundation / checks (network) (push) Successful in 13m43s
Foundation / checks (tsan) (push) Successful in 8m11s
Foundation / checks (postgres) (push) Failing after 20m58s
Foundation / checks (checks) (push) Successful in 33m53s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
@@ -5698,3 +5698,11 @@ the `performance-move-const-arg` clang-tidy warning on the v17 outcome adapter.
|
|||||||
Both were corrected. clang-format 19.1.5 dry-run and clang-tidy 19.1.5 on
|
Both were corrected. clang-format 19.1.5 dry-run and clang-tidy 19.1.5 on
|
||||||
`region_lease_store.cpp` pass locally. Awaiting CI rerun for the database,
|
`region_lease_store.cpp` pass locally. Awaiting CI rerun for the database,
|
||||||
migration, host test and repository checks; no local runtime pass is claimed.
|
migration, host test and repository checks; no local runtime pass is claimed.
|
||||||
|
|
||||||
|
The subsequent CI build found one more `performance-move-const-arg` and eight
|
||||||
|
`bugprone-unchecked-optional-access` errors in `primitive_region_host.cpp`.
|
||||||
|
Removed the ineffective move and made lease grants and nested optional values
|
||||||
|
explicitly checked before access. clang-format 19.1.5 dry-run, clang-tidy 19.1.5
|
||||||
|
with warnings-as-errors, GCC 13.2 Release/NDEBUG compilation with warnings-as-
|
||||||
|
errors, and `git diff --check` pass locally. PostgreSQL integration remains
|
||||||
|
unavailable in this Windows environment; awaiting CI rerun.
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ bool valid(const PrimitiveHostConfig& c) {
|
|||||||
}
|
}
|
||||||
PrimitiveHostReply reply(PrimitiveHostReplyKind kind, persistence::LifeReservation reservation,
|
PrimitiveHostReply reply(PrimitiveHostReplyKind kind, persistence::LifeReservation reservation,
|
||||||
std::optional<persistence::PrimitiveLifeBinding> published = {}) {
|
std::optional<persistence::PrimitiveLifeBinding> published = {}) {
|
||||||
return {kind, reservation, std::move(published)};
|
return {kind, reservation, published};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -108,7 +108,15 @@ void PrimitiveRegionHost::acquire() {
|
|||||||
state_ = std::move(recovered->state);
|
state_ = std::move(recovered->state);
|
||||||
committed_ = std::move(recovered->committed);
|
committed_ = std::move(recovered->committed);
|
||||||
pending_.reset();
|
pending_.reset();
|
||||||
status_.epoch = authority_.grant()->epoch;
|
const auto grant = authority_.grant();
|
||||||
|
if (!grant) {
|
||||||
|
authority_.fence();
|
||||||
|
status_.phase = HostPhase::quarantined;
|
||||||
|
state_.reset();
|
||||||
|
committed_.reset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
status_.epoch = grant->epoch;
|
||||||
status_.committed_tick = committed_->head.end_tick;
|
status_.committed_tick = committed_->head.end_tick;
|
||||||
status_.simulated_tick = committed_->head.end_tick;
|
status_.simulated_tick = committed_->head.end_tick;
|
||||||
status_.committed_sequence = committed_->head.sequence;
|
status_.committed_sequence = committed_->head.sequence;
|
||||||
@@ -220,11 +228,13 @@ std::optional<persistence::LeaseGrant> PrimitiveRegionHost::authority() const {
|
|||||||
|
|
||||||
PrimitiveHostReply PrimitiveRegionHost::query(const persistence::Uuid& account,
|
PrimitiveHostReply PrimitiveRegionHost::query(const persistence::Uuid& account,
|
||||||
std::uint64_t generation, std::uint64_t request) {
|
std::uint64_t generation, std::uint64_t request) {
|
||||||
if (!database() || !authority_.grant())
|
if (!database())
|
||||||
return reply(PrimitiveHostReplyKind::unavailable, {});
|
return reply(PrimitiveHostReplyKind::unavailable, {});
|
||||||
auto outcome =
|
const auto grant = authority_.grant();
|
||||||
persistence::query_primitive_life(*db_, config_.key, *authority_.grant(), account,
|
if (!grant)
|
||||||
generation, request, config_.lease.commit_timeout);
|
return reply(PrimitiveHostReplyKind::unavailable, {});
|
||||||
|
auto outcome = persistence::query_primitive_life(*db_, config_.key, *grant, account, generation,
|
||||||
|
request, config_.lease.commit_timeout);
|
||||||
if (!outcome) {
|
if (!outcome) {
|
||||||
if (outcome.error().kind == persistence::LifeReservationError::unknown ||
|
if (outcome.error().kind == persistence::LifeReservationError::unknown ||
|
||||||
outcome.error().kind == persistence::LifeReservationError::store)
|
outcome.error().kind == persistence::LifeReservationError::store)
|
||||||
@@ -233,9 +243,10 @@ PrimitiveHostReply PrimitiveRegionHost::query(const persistence::Uuid& account,
|
|||||||
status_.ready = false;
|
status_.ready = false;
|
||||||
return reply(PrimitiveHostReplyKind::unknown, {});
|
return reply(PrimitiveHostReplyKind::unknown, {});
|
||||||
}
|
}
|
||||||
if (!*outcome)
|
const auto& maybe_value = outcome.value();
|
||||||
|
if (!maybe_value.has_value())
|
||||||
return reply(PrimitiveHostReplyKind::unknown, {});
|
return reply(PrimitiveHostReplyKind::unknown, {});
|
||||||
const auto& value = **outcome;
|
const auto& value = maybe_value.value();
|
||||||
if (value.published)
|
if (value.published)
|
||||||
return reply(PrimitiveHostReplyKind::born, value.reservation, value.published);
|
return reply(PrimitiveHostReplyKind::born, value.reservation, value.published);
|
||||||
if (value.reservation.region != config_.key.region)
|
if (value.reservation.region != config_.key.region)
|
||||||
@@ -250,6 +261,9 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
|||||||
std::uint32_t rules) {
|
std::uint32_t rules) {
|
||||||
if (!status_.ready || !state_ || !committed_ || !authority_.may_begin_commit(LeaseClock::now()))
|
if (!status_.ready || !state_ || !committed_ || !authority_.may_begin_commit(LeaseClock::now()))
|
||||||
return reply(PrimitiveHostReplyKind::unavailable, {});
|
return reply(PrimitiveHostReplyKind::unavailable, {});
|
||||||
|
const auto grant = authority_.grant();
|
||||||
|
if (!grant)
|
||||||
|
return reply(PrimitiveHostReplyKind::unavailable, {});
|
||||||
if (account == persistence::Uuid{} || generation == 0 || request == 0 || rules == 0)
|
if (account == persistence::Uuid{} || generation == 0 || request == 0 || rules == 0)
|
||||||
return reply(PrimitiveHostReplyKind::refused, {});
|
return reply(PrimitiveHostReplyKind::refused, {});
|
||||||
if (pending_) {
|
if (pending_) {
|
||||||
@@ -262,15 +276,15 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
|||||||
return reply(PrimitiveHostReplyKind::unknown, pending_->reservation);
|
return reply(PrimitiveHostReplyKind::unknown, pending_->reservation);
|
||||||
}
|
}
|
||||||
persistence::PrimitivePreparedCommit prepared;
|
persistence::PrimitivePreparedCommit prepared;
|
||||||
if (pending_->prepared) {
|
const auto prepared_value = pending_->prepared;
|
||||||
prepared = *pending_->prepared;
|
if (prepared_value.has_value()) {
|
||||||
|
prepared = prepared_value.value();
|
||||||
} else {
|
} else {
|
||||||
// Re-entering the adapter with the same predecessor, trace and commit recreates
|
// Re-entering the adapter with the same predecessor, trace and commit recreates
|
||||||
// the exact canonical bytes when the earlier failure happened before SQL.
|
// the exact canonical bytes when the earlier failure happened before SQL.
|
||||||
auto published = persistence::publish_primitive_batch(
|
auto published = persistence::publish_primitive_batch(
|
||||||
*db_, *objects_, *authority_.grant(), *committed_, pending_->batch,
|
*db_, *objects_, *grant, *committed_, pending_->batch, *pending_->candidate,
|
||||||
*pending_->candidate, pending_->commit, config_.build,
|
pending_->commit, config_.build, config_.lease.commit_timeout);
|
||||||
config_.lease.commit_timeout);
|
|
||||||
if (published) {
|
if (published) {
|
||||||
state_ = std::move(pending_->candidate);
|
state_ = std::move(pending_->candidate);
|
||||||
committed_ = published->committed;
|
committed_ = published->committed;
|
||||||
@@ -340,9 +354,9 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
|||||||
if (existing.kind != PrimitiveHostReplyKind::unknown &&
|
if (existing.kind != PrimitiveHostReplyKind::unknown &&
|
||||||
existing.kind != PrimitiveHostReplyKind::pending)
|
existing.kind != PrimitiveHostReplyKind::pending)
|
||||||
return existing;
|
return existing;
|
||||||
auto reserved = persistence::reserve_primitive_life(*db_, config_.key, *authority_.grant(),
|
auto reserved =
|
||||||
account, generation, request, rules,
|
persistence::reserve_primitive_life(*db_, config_.key, *grant, account, generation, request,
|
||||||
config_.lease.commit_timeout);
|
rules, config_.lease.commit_timeout);
|
||||||
if (!reserved) {
|
if (!reserved) {
|
||||||
if (reserved.error().kind == persistence::LifeReservationError::unknown) {
|
if (reserved.error().kind == persistence::LifeReservationError::unknown) {
|
||||||
db_.reset();
|
db_.reset();
|
||||||
@@ -362,9 +376,9 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
|||||||
if (reserved->refusal != persistence::LifeRefusal::none)
|
if (reserved->refusal != persistence::LifeRefusal::none)
|
||||||
return reply(PrimitiveHostReplyKind::refused, *reserved);
|
return reply(PrimitiveHostReplyKind::refused, *reserved);
|
||||||
const auto refuse = [&](persistence::LifeRefusal reason) {
|
const auto refuse = [&](persistence::LifeRefusal reason) {
|
||||||
const auto recorded = persistence::reject_primitive_life(
|
const auto recorded =
|
||||||
*db_, config_.key, *authority_.grant(), account, generation, request, reason,
|
persistence::reject_primitive_life(*db_, config_.key, *grant, account, generation,
|
||||||
config_.lease.commit_timeout);
|
request, reason, config_.lease.commit_timeout);
|
||||||
if (!recorded) {
|
if (!recorded) {
|
||||||
if (recorded.error().kind == persistence::LifeReservationError::unknown)
|
if (recorded.error().kind == persistence::LifeReservationError::unknown)
|
||||||
db_.reset();
|
db_.reset();
|
||||||
@@ -428,7 +442,7 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
|||||||
authority_.fence();
|
authority_.fence();
|
||||||
return reply(PrimitiveHostReplyKind::unavailable, *reserved);
|
return reply(PrimitiveHostReplyKind::unavailable, *reserved);
|
||||||
}
|
}
|
||||||
auto commit = authority_.grant()->holder;
|
auto commit = grant->holder;
|
||||||
const auto sequence = committed_->head.sequence + 1;
|
const auto sequence = committed_->head.sequence + 1;
|
||||||
for (unsigned i = 0; i < 8; ++i)
|
for (unsigned i = 0; i < 8; ++i)
|
||||||
commit[8 + i] = static_cast<std::uint8_t>((sequence >> (i * 8U)) & 0xffU);
|
commit[8 + i] = static_cast<std::uint8_t>((sequence >> (i * 8U)) & 0xffU);
|
||||||
@@ -441,7 +455,7 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
|||||||
commit,
|
commit,
|
||||||
{}});
|
{}});
|
||||||
auto published = persistence::publish_primitive_batch(
|
auto published = persistence::publish_primitive_batch(
|
||||||
*db_, *objects_, *authority_.grant(), *committed_, pending_->batch, *pending_->candidate,
|
*db_, *objects_, *grant, *committed_, pending_->batch, *pending_->candidate,
|
||||||
pending_->commit, config_.build, config_.lease.commit_timeout);
|
pending_->commit, config_.build, config_.lease.commit_timeout);
|
||||||
if (!published) {
|
if (!published) {
|
||||||
const auto& failure = published.error();
|
const auto& failure = published.error();
|
||||||
|
|||||||
Reference in New Issue
Block a user