Invalidate instance copies when player data is imported or deleted

Generations alone could not order a repair against copies held by
instances. Deleting dropped the watermark, so a stale instance could
skip downloading the new baseline. An import could land on the same
generation as an upload that never reached the controller, and the
instance would then keep its own copy.

Imports and deletes now bump a per-player epoch, which the controller
returns on acquire and checks on upload. Instances throw away a copy
from an earlier epoch, and deleted players keep their generation and
epoch in player_sync_deleted.json. A restarted download also takes the
new generation instead of the outdated one.

Generations in player data must now be non-negative integers, so an
invalid import is refused before it reaches the datastore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-17 18:52:54 +00:00
1 parent 1d14148606
commit f12b016cec
9 files changed
+159 -39

No files matched your search

+7 -2
View File
@@ -4,6 +4,8 @@ import { StringEnum, jsonArray } from "@clusterio/lib";
// .\module\serialize.lua:serialize.serialize_player()
export type IpcPlayerData = {
generation: number,
/** Bumped when the stored data is imported or deleted, invalidating copies held by instances */
epoch?: number,
name: string,
controller?: string,
color?: number[],
@@ -27,7 +29,8 @@ export type IpcPlayerData = {
}
const jsonPlayerData = Type.Object({
generation: Type.Number(),
generation: Type.Integer({ minimum: 0 }),
epoch: Type.Optional(Type.Integer({ minimum: 0 })),
name: Type.String(),
});
@@ -37,6 +40,7 @@ export class AcquireResponse {
public generation?: number,
public hasData?: boolean,
public message?: string,
public epoch?: number,
) {
}
@@ -45,10 +49,11 @@ export class AcquireResponse {
"generation": Type.Optional(Type.Integer()),
"hasData": Type.Optional(Type.Boolean()),
"message": Type.Optional(Type.String()),
"epoch": Type.Optional(Type.Integer()),
});
static fromJSON(json: Static<typeof AcquireResponse.jsonSchema>): AcquireResponse {
return new this(json.status, json.generation, json.hasData, json.message);
return new this(json.status, json.generation, json.hasData, json.message, json.epoch);
}
};
export class AcquireRequest {