fix(clients): withdraw delete tombstones for clients any serialized write re-creates

Deleting a client tombstones its email for 90s, so a node snapshot taken
before the delete reached the node cannot resurrect it. Client create and
bulk create withdrew that tombstone, but a client re-created through
InboundService.AddInbound (SyncInbound / syncInboundClients) did not. On a
master, re-adding a node inbound with a just-deleted email therefore let
the next node merge filter the new client out of the snapshot, unlink it
from its inbound and mark it a sync orphan; ReapSyncOrphans then
hard-deleted it 15 minutes later and the node lost it.

syncInboundClients now records the emails it creates on the serialized
transaction, and runSerializedTx withdraws their tombstones only after the
commit, still on the writer, so no merge runs in between and a rolled-back
create leaves the tombstone standing. The per-call withdraws in Create and
bulkCreate are covered by this and removed.

Co-authored-by: FZ1010 <FZ1010@users.noreply.github.com>
This commit is contained in:
Farhan Zare
2026-10-23 13:30:13 -04:00
committed by GitHub
parent f172bc3f10
commit 47be06358e
6 changed files with 129 additions and 14 deletions
+12
View File
@@ -119,6 +119,18 @@ func withdrawClientTombstones(emails ...string) {
}
}
// liftTombstonesOnCommit withdraws the delete tombstones of clients a serialized
// tx re-created once it commits; a rolled-back create leaves them standing.
func liftTombstonesOnCommit(tx *gorm.DB, created []*model.ClientRecord) {
state := serializedTxOf(tx)
if state == nil {
return
}
for _, rec := range created {
state.createdClientEmails = append(state.createdClientEmails, rec.Email)
}
}
func tombstoneClientEmails(emails []string) {
if len(emails) == 0 {
return