Fix CI formatting and tidy findings
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Successful in 12m38s
Foundation / checks (network) (push) Successful in 14m7s
Foundation / checks (tsan) (push) Successful in 8m11s
Foundation / checks (postgres) (push) Failing after 18m3s
Foundation / checks (checks) (push) Successful in 33m8s
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 1m56s
Foundation / checks (client) (push) Successful in 12m38s
Foundation / checks (network) (push) Successful in 14m7s
Foundation / checks (tsan) (push) Successful in 8m11s
Foundation / checks (postgres) (push) Failing after 18m3s
Foundation / checks (checks) (push) Successful in 33m8s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
@@ -22,8 +22,8 @@ using persistence::LeaseClock;
|
||||
using persistence::LeaseStoreError;
|
||||
|
||||
bool valid(const PrimitiveHostConfig& c) {
|
||||
return c.key.world != 0 && c.key.region != 0 && c.frame != 0 &&
|
||||
persistence::valid(c.lease) && c.build != persistence::Sha256Digest{} &&
|
||||
return c.key.world != 0 && c.key.region != 0 && c.frame != 0 && persistence::valid(c.lease) &&
|
||||
c.build != persistence::Sha256Digest{} &&
|
||||
std::ranges::find(c.retained_builds, c.build) != c.retained_builds.end();
|
||||
}
|
||||
PrimitiveHostReply reply(PrimitiveHostReplyKind kind, persistence::LifeReservation reservation,
|
||||
@@ -32,8 +32,9 @@ PrimitiveHostReply reply(PrimitiveHostReplyKind kind, persistence::LifeReservati
|
||||
}
|
||||
} // namespace
|
||||
|
||||
PrimitiveRegionHost::PrimitiveRegionHost(PrimitiveHostConfig config, PrimitiveConnect connect,
|
||||
std::unique_ptr<persistence::FilesystemObjectStore> objects)
|
||||
PrimitiveRegionHost::PrimitiveRegionHost(
|
||||
PrimitiveHostConfig config, PrimitiveConnect connect,
|
||||
std::unique_ptr<persistence::FilesystemObjectStore> objects)
|
||||
: config_{std::move(config)}, connect_{std::move(connect)}, objects_{std::move(objects)},
|
||||
authority_{config_.lease} {}
|
||||
|
||||
@@ -44,8 +45,8 @@ PrimitiveRegionHost::create(PrimitiveHostConfig config, PrimitiveConnect connect
|
||||
std::unique_ptr<persistence::FilesystemObjectStore> objects) {
|
||||
if (!valid(config) || !connect || !objects)
|
||||
return std::unexpected{PrimitiveHostError::configuration};
|
||||
return std::unique_ptr<PrimitiveRegionHost>{new PrimitiveRegionHost{
|
||||
std::move(config), std::move(connect), std::move(objects)}};
|
||||
return std::unique_ptr<PrimitiveRegionHost>{
|
||||
new PrimitiveRegionHost{std::move(config), std::move(connect), std::move(objects)}};
|
||||
}
|
||||
|
||||
bool PrimitiveRegionHost::database() {
|
||||
@@ -166,9 +167,11 @@ void PrimitiveRegionHost::refresh() {
|
||||
authority_.may_originate(LeaseClock::now());
|
||||
status_.epoch = lease ? lease->epoch : 0;
|
||||
status_.lease_remaining_ms =
|
||||
status_.ready ? static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
authority_.deadline() - LeaseClock::now()).count())
|
||||
: 0;
|
||||
status_.ready
|
||||
? static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
authority_.deadline() - LeaseClock::now())
|
||||
.count())
|
||||
: 0;
|
||||
}
|
||||
|
||||
const HostStatus& PrimitiveRegionHost::step() {
|
||||
@@ -196,8 +199,8 @@ void PrimitiveRegionHost::drain() {
|
||||
pending_.reset();
|
||||
const auto grant = authority_.grant();
|
||||
if (grant && authority_.may_originate(LeaseClock::now()) && database()) {
|
||||
const auto released = persistence::release_region_lease(
|
||||
*db_, config_.key, *grant, config_.lease.renew_timeout);
|
||||
const auto released = persistence::release_region_lease(*db_, config_.key, *grant,
|
||||
config_.lease.renew_timeout);
|
||||
if (!released)
|
||||
db_.reset();
|
||||
}
|
||||
@@ -216,13 +219,12 @@ std::optional<persistence::LeaseGrant> PrimitiveRegionHost::authority() const {
|
||||
}
|
||||
|
||||
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())
|
||||
return reply(PrimitiveHostReplyKind::unavailable, {});
|
||||
auto outcome = persistence::query_primitive_life(*db_, config_.key, *authority_.grant(),
|
||||
account, generation, request,
|
||||
config_.lease.commit_timeout);
|
||||
auto outcome =
|
||||
persistence::query_primitive_life(*db_, config_.key, *authority_.grant(), account,
|
||||
generation, request, config_.lease.commit_timeout);
|
||||
if (!outcome) {
|
||||
if (outcome.error().kind == persistence::LifeReservationError::unknown ||
|
||||
outcome.error().kind == persistence::LifeReservationError::store)
|
||||
@@ -244,8 +246,7 @@ PrimitiveHostReply PrimitiveRegionHost::query(const persistence::Uuid& account,
|
||||
}
|
||||
|
||||
PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& account,
|
||||
std::uint64_t generation,
|
||||
std::uint64_t request,
|
||||
std::uint64_t generation, std::uint64_t request,
|
||||
std::uint32_t rules) {
|
||||
if (!status_.ready || !state_ || !committed_ || !authority_.may_begin_commit(LeaseClock::now()))
|
||||
return reply(PrimitiveHostReplyKind::unavailable, {});
|
||||
@@ -304,8 +305,8 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
||||
status_.phase = HostPhase::quarantined;
|
||||
return reply(PrimitiveHostReplyKind::unavailable, reservation);
|
||||
}
|
||||
auto resolved = persistence::retry_primitive_prepared(
|
||||
*db_, prepared, config_.lease.commit_timeout);
|
||||
auto resolved =
|
||||
persistence::retry_primitive_prepared(*db_, prepared, config_.lease.commit_timeout);
|
||||
if (!resolved) {
|
||||
if (resolved.error().kind == persistence::PublicationError::unknown) {
|
||||
db_.reset();
|
||||
@@ -339,9 +340,9 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
||||
if (existing.kind != PrimitiveHostReplyKind::unknown &&
|
||||
existing.kind != PrimitiveHostReplyKind::pending)
|
||||
return existing;
|
||||
auto reserved = persistence::reserve_primitive_life(
|
||||
*db_, config_.key, *authority_.grant(), account, generation, request, rules,
|
||||
config_.lease.commit_timeout);
|
||||
auto reserved = persistence::reserve_primitive_life(*db_, config_.key, *authority_.grant(),
|
||||
account, generation, request, rules,
|
||||
config_.lease.commit_timeout);
|
||||
if (!reserved) {
|
||||
if (reserved.error().kind == persistence::LifeReservationError::unknown) {
|
||||
db_.reset();
|
||||
@@ -386,7 +387,7 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
||||
auto& source = state_->balances().front();
|
||||
const auto enough = [&] {
|
||||
if (source.energy.value < endowed->body.energy.value + endowed->reserve.energy.value +
|
||||
endowed->construction.value)
|
||||
endowed->construction.value)
|
||||
return false;
|
||||
for (std::size_t i = 0; i < source.matter.size(); ++i)
|
||||
if (source.matter[i].value < endowed->body.matter[i].value)
|
||||
@@ -395,8 +396,7 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
||||
};
|
||||
if (!enough())
|
||||
return refuse(persistence::LifeRefusal::insufficient_funding);
|
||||
if (committed_->head.end_tick == UINT64_MAX ||
|
||||
committed_->head.sequence == UINT64_MAX) {
|
||||
if (committed_->head.end_tick == UINT64_MAX || committed_->head.sequence == UINT64_MAX) {
|
||||
status_.phase = HostPhase::quarantined;
|
||||
status_.ready = false;
|
||||
authority_.fence();
|
||||
@@ -412,8 +412,8 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
||||
}
|
||||
const auto end_tick = committed_->head.end_tick + 1;
|
||||
PrimitiveBatch batch{{config_.key.world, config_.key.region, config_.frame,
|
||||
committed_->head.commit, *predecessor_digest,
|
||||
committed_->head.end_tick, end_tick},
|
||||
committed_->head.commit, *predecessor_digest, committed_->head.end_tick,
|
||||
end_tick},
|
||||
{{{account, request}, reserved->identity, generation, {end_tick}}}};
|
||||
auto candidate = replay_primitive_batch(*state_, batch);
|
||||
if (!candidate) {
|
||||
@@ -432,8 +432,14 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
|
||||
const auto sequence = committed_->head.sequence + 1;
|
||||
for (unsigned i = 0; i < 8; ++i)
|
||||
commit[8 + i] = static_cast<std::uint8_t>((sequence >> (i * 8U)) & 0xffU);
|
||||
pending_ = std::make_unique<Pending>(Pending{account, generation, request, *reserved,
|
||||
std::move(batch), std::move(*candidate), commit, {}});
|
||||
pending_ = std::make_unique<Pending>(Pending{account,
|
||||
generation,
|
||||
request,
|
||||
*reserved,
|
||||
std::move(batch),
|
||||
std::move(*candidate),
|
||||
commit,
|
||||
{}});
|
||||
auto published = persistence::publish_primitive_batch(
|
||||
*db_, *objects_, *authority_.grant(), *committed_, pending_->batch, *pending_->candidate,
|
||||
pending_->commit, config_.build, config_.lease.commit_timeout);
|
||||
|
||||
Reference in New Issue
Block a user