change ids
All checks were successful
Build and Publish / Metadata (push) Successful in 3s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 50s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m25s

This commit is contained in:
matst80
2025-10-10 21:50:18 +00:00
parent b0e6c8eca8
commit e48a2590bd
13 changed files with 312 additions and 510 deletions

View File

@@ -205,14 +205,11 @@ func (p *SyncedPool) initializeRemote(remote *RemoteHostGRPC) {
count := 0
// Record remote ownership (first-touch model) instead of spawning remote grain proxies.
p.mu.Lock()
for _, idStr := range reply.CartIds {
if idStr == "" {
continue
}
cid := ToCartId(idStr)
for _, cid := range reply.CartIds {
// Only set if not already claimed (first claim wins)
if _, exists := p.remoteOwners[cid]; !exists {
p.remoteOwners[cid] = remote.Host
if _, exists := p.remoteOwners[CartId(cid)]; !exists {
p.remoteOwners[CartId(cid)] = remote.Host
}
count++
}
@@ -383,7 +380,7 @@ func (p *SyncedPool) DebugOwnerHost(id CartId) string {
func (p *SyncedPool) removeLocalGrain(id CartId) {
p.mu.Lock()
delete(p.local.grains, LegacyToCartKey(id))
delete(p.local.grains, uint64(id))
p.mu.Unlock()
}
@@ -404,7 +401,7 @@ var ErrNotOwner = fmt.Errorf("not owner")
func (p *SyncedPool) resolveOwnerFirstTouch(id CartId) (string, error) {
// Fast local existence check
p.local.mu.RLock()
_, existsLocal := p.local.grains[LegacyToCartKey(id)]
_, existsLocal := p.local.grains[uint64(id)]
p.local.mu.RUnlock()
if existsLocal {
return p.LocalHostname, nil
@@ -485,14 +482,18 @@ func (p *SyncedPool) AdoptRemoteOwnership(host string, ids []string) {
if s == "" {
continue
}
id := ToCartId(s)
parsed, ok := ParseCartId(s)
if !ok {
continue // skip invalid cart id strings
}
id := parsed
// Do not overwrite if already claimed by another host (first wins).
if existing, ok := p.remoteOwners[id]; ok && existing != host {
continue
}
// Skip if we own locally (local wins for our own process)
p.local.mu.RLock()
_, localHas := p.local.grains[LegacyToCartKey(id)]
_, localHas := p.local.grains[uint64(id)]
p.local.mu.RUnlock()
if localHas {
continue