Read what a machine has from its haves: reported-and-current, the bus list, a given value's first good start; drop the digest of a send (migration 0110) (release 6, issue 1945 B8)
This commit is contained in:
+13
-13
@@ -79,18 +79,18 @@ type GivenReplaced struct {
|
||||
}
|
||||
|
||||
// ReplaceGivenAfterStart replaces every given value on a machine whose module has now started well
|
||||
// under the mesh on it (novox/hq ADR 0228), and answers what it replaced; the caller sends the
|
||||
// under the mesh on it (novox/hq ADR 0228), and answers what it replaced; the caller composes the
|
||||
// machines each names.
|
||||
//
|
||||
// **The signal is the machine's clean report of the declaration it was last sent** — every resource
|
||||
// applied, nothing failed or refused — **when that declaration was sent after the value was given**,
|
||||
// so it is the start on the given value that counts, not an older one. On an adopted machine the
|
||||
// module must also be taken: until then the mesh runs nothing of it, and nothing has started under
|
||||
// the mesh. Each row is claimed by clearing its mark before it is remade, so two reports arriving
|
||||
// together replace a value once; a remake that fails puts the mark back, and the next good report
|
||||
// tries again.
|
||||
func (i *Inventory) ReplaceGivenAfterStart(ctx context.Context, node, declared string) ([]GivenReplaced, error) {
|
||||
if declared == "" {
|
||||
// **The signal is the machine's have of the module being healthy** (ADR 0539 §9): started names, per
|
||||
// module, when the node-engine wrote a have of it that is running and healthy at its composition.
|
||||
// A value counts when that is **after it was given**, so it is the start on the given value that
|
||||
// counts, not an older one. On an adopted machine the module must also be taken: until then the mesh
|
||||
// runs nothing of it, and nothing has started under the mesh. Each row is claimed by clearing its mark
|
||||
// before it is remade, so two haves arriving together replace a value once; a remake that fails puts
|
||||
// the mark back, and the next healthy have tries again.
|
||||
func (i *Inventory) ReplaceGivenAfterStart(ctx context.Context, node string, started map[string]time.Time) ([]GivenReplaced, error) {
|
||||
if len(started) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
// Only a module assigned there, from the assignments bucket.
|
||||
@@ -106,10 +106,10 @@ func (i *Inventory) ReplaceGivenAfterStart(ctx context.Context, node, declared s
|
||||
`select s.node, s.module, s.name, s.replace_after_start
|
||||
from module_secret s
|
||||
join node n on n.id = s.node
|
||||
where n.name = $1 and n.sent = $2 and n.sent_at > s.replace_after_start
|
||||
where n.name = $1
|
||||
and s.origin = 'accepted' and s.replace_after_start is not null
|
||||
and (not n.adopted or exists (select 1 from taken t where t.node = s.node and t.module = s.module))
|
||||
order by s.module, s.name`, node, declared)
|
||||
order by s.module, s.name`, node)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func (i *Inventory) ReplaceGivenAfterStart(ctx context.Context, node, declared s
|
||||
rows.Close()
|
||||
return nil, err
|
||||
}
|
||||
if !assignedHere[d.module] {
|
||||
if !assignedHere[d.module] || !started[d.module].After(d.given) {
|
||||
continue
|
||||
}
|
||||
dues = append(dues, d)
|
||||
|
||||
Reference in New Issue
Block a user