feat: live updates move every server onto a new build without a restart

With new binaries in place, master moves everything onto them while the
server keeps running (the dashboard's Live update, /liveupdate or SIGUSR2 to
master):

- database migrations of the new build first; a failure stops there
- UGC finishes the jobs it is running (queued rows stay pending), auth
  restarts, chat hands its teams to master for the next chat server; master
  starts the new processes and retries ones that don't come back
- once the new chat server is up (CHAT_SERVER_READY) every world connects at
  once and sends its players again (LoginSessionNotify resync, no login logged)
- every world instance is replaced with an instance migration: public worlds
  and private ones (same password) at once, properties after the old instance
  saved and froze the property (MIGRATE_PREPARE: no building, claiming or
  saving there any more), activity zones and character select once their
  players left or after a wait; empty instances just stop, zones in
  prestart_worlds get a new one first
- the dashboard restarts last and picks the status up again

Players land where they stood (position carried in CarriedPlayerState, also on
properties and Moon Base). Draining instances get no new players
(InstanceMigration::AcceptsNewPlayers) and show as "Moving players" in the
world list. The order lives in LiveUpdateMachine.h without master state and is
unit tested; master's glue is LiveUpdateCoordinator. Master itself is not
replaced. Message IDs are appended only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-28 15:01:05 -05:00
parent bfc45dc662
commit 109a936798
47 changed files with 3213 additions and 59 deletions

View File

@@ -117,6 +117,8 @@ bool PropertyManagementComponent::IsBestFriend(const LWOOBJID player) const {
}
bool PropertyManagementComponent::CanBuild(const Entity& player) const {
// Handed off to a new instance: building happens there
if (frozen) return false;
const bool bestFriendsBuild = PropertyBuilders::BestFriendsBuild();
PropertyBuilders::Player state{ .id = player.GetObjectID(), .isBuilding = builders.contains(player.GetObjectID()) };
// Only a best friend needs the lookup
@@ -267,7 +269,7 @@ void PropertyManagementComponent::UpdatePropertyDetails(std::string name, std::s
}
bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
if (owner != LWOOBJID_EMPTY) {
if (owner != LWOOBJID_EMPTY || frozen) {
return false;
}
@@ -510,6 +512,8 @@ void PropertyManagementComponent::SendModelsOnProperty() const {
}
void PropertyManagementComponent::UpdateModelPosition(Entity& builder, const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation) {
// Handed off to a new instance (live update): nothing changes here any more
if (frozen) return;
LOG("Placing model <%f, %f, %f>", position.x, position.y, position.z);
auto* entity = &builder;
@@ -560,6 +564,7 @@ void PropertyManagementComponent::UpdateModelPosition(Entity& builder, const LWO
}
void PropertyManagementComponent::DeleteModel(Entity& builder, const LWOOBJID id, const int deleteReason) {
if (frozen) return;
LOG("Delete model: (%llu) (%i)", id, deleteReason);
auto* model = Game::entityManager->GetEntity(id);
@@ -761,6 +766,9 @@ void PropertyManagementComponent::Load() {
}
void PropertyManagementComponent::Save() {
// Handed off to a new instance (live update): what it saves is what counts
if (frozen) return;
// From the property's own ids: it saves whoever is here (the owner may not be)
if (propertyId == LWOOBJID_EMPTY || owner == LWOOBJID_EMPTY) {
return;
@@ -833,6 +841,29 @@ void PropertyManagementComponent::Save() {
DashboardNotify::Changed("properties", propertyId);
}
void PropertyManagementComponent::FreezeForHandOff() {
if (frozen) return;
// Everyone still building stops (their models are kept as they are now), and nobody can start again
std::vector<LWOOBJID> building(builders.begin(), builders.end());
for (const auto id : building) {
auto* builder = Game::entityManager->GetEntity(id);
if (builder) EndBuilding(*builder);
else builders.erase(id);
}
Save();
frozen = true;
// Takes the build rights the clients were given away (CanBuild is false for everyone now)
UpdateBuildRights();
LOG("Property %llu (clone %u) saved and handed off to a new instance", propertyId, clone_Id);
}
void PropertyManagementComponent::Unfreeze() {
if (!frozen) return;
frozen = false;
UpdateBuildRights();
LOG("Property %llu (clone %u) is no longer handed off", propertyId, clone_Id);
}
void PropertyManagementComponent::AddModel(LWOOBJID modelId, LWOOBJID spawnerId) {
models[modelId] = spawnerId;
}