mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
docs: trace holder checks and nonblocking lookup to their invariants
This commit is contained in:
1 parent
476b5fceb9
commit
a86f07d71a
6 files changed
+11
-7
No files matched your search
@@ -158,7 +158,8 @@ type PublishedLine struct {
|
||||
}
|
||||
|
||||
// PublishedAuthorityLine reads one committed line under leaf leaseMu. Identity
|
||||
// checks on renewal must not wait for p.mu, which spans authority store I/O.
|
||||
// checks on renewal must not wait for p.mu, which spans authority store I/O
|
||||
// (INV-LEASE-VIEW-001, INV-WS-RENEW-NONBLOCKING-001).
|
||||
func (p *Publisher) PublishedAuthorityLine(volume string) (PublishedLine, bool) {
|
||||
p.leaseMu.Lock()
|
||||
defer p.leaseMu.Unlock()
|
||||
|
||||
@@ -65,6 +65,8 @@ func (h *Host) workspaceEndpointsAvailable(b lifecycle.WorkspaceBinding) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// workspaceSourceHost resolves explicit holder membership for
|
||||
// INV-ASSIGNMENT-HOLDER-IDENTITY-001; endpoints never select a server.
|
||||
func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string {
|
||||
if state := h.Publisher().WorkspaceState(volume); state != nil {
|
||||
for _, r := range state.Moves {
|
||||
@@ -79,7 +81,8 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string
|
||||
return h.placementSourceHost(volume, replica)
|
||||
}
|
||||
|
||||
// placementSourceHost uses explicit membership, never endpoint inference.
|
||||
// placementSourceHost uses committed membership, never endpoint inference
|
||||
// (INV-ASSIGNMENT-HOLDER-IDENTITY-001, INV-WS-RENEW-NONBLOCKING-001).
|
||||
func (h *Host) placementSourceHost(volume, replica string) string {
|
||||
if h.lifecycle != nil {
|
||||
if p, ok := h.lifecycle.Placements.GetPlacementSnapshot(volume); ok {
|
||||
|
||||
@@ -90,7 +90,7 @@ func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.Workspace
|
||||
if err := s.workspaceVolumeForRenewal(q.GetVolumeId()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// r2.34 AUTHORITY: a replica id can move between servers.
|
||||
// INV-ASSIGNMENT-HOLDER-IDENTITY-001: a replica id can move between servers.
|
||||
line, ok := s.host.Publisher().PublishedAuthorityLine(q.GetVolumeId())
|
||||
server := line.IssuedHost
|
||||
if server == "" {
|
||||
|
||||
@@ -2,7 +2,7 @@ package volume
|
||||
|
||||
import control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
|
||||
// assignmentNamesSelf implements r2.34 AUTHORITY. Missing server identity is
|
||||
// assignmentNamesSelf implements INV-ASSIGNMENT-HOLDER-IDENTITY-001. Missing server identity is
|
||||
// refused; endpoints qualify identity only when the master carries them.
|
||||
func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool {
|
||||
return f.GetServerId() != "" && f.GetServerId() == h.cfg.ServerID &&
|
||||
|
||||
@@ -235,7 +235,7 @@ func (h *Host) recordOtherLine(f *control.AssignmentFact) {
|
||||
// is the canonical safe deep-copy for proto messages.
|
||||
cp := proto.Clone(f).(*control.AssignmentFact)
|
||||
h.otherMu.Lock()
|
||||
// A stale replay must not erase the newer foreign-holder fence (r2.34).
|
||||
// A stale replay must not erase the newer foreign-holder fence (INV-ASSIGNMENT-HOLDER-IDENTITY-001).
|
||||
if old := h.lastOther; old != nil && (cp.Epoch < old.Epoch || cp.Epoch == old.Epoch && cp.EndpointVersion < old.EndpointVersion) {
|
||||
h.otherMu.Unlock()
|
||||
return
|
||||
@@ -808,7 +808,7 @@ func (h *Host) streamOnce(ctx context.Context) error {
|
||||
// OnAssignment could flip the projection Healthy before peers were
|
||||
// installed, admitting local-only writes with zero fan-out.
|
||||
func (h *Host) applyFact(fact *control.AssignmentFact) {
|
||||
// r2.34 AUTHORITY: matching r1 and loopback endpoints do not identify a host.
|
||||
// INV-ASSIGNMENT-HOLDER-IDENTITY-001: matching r1 and loopback endpoints do not identify a host.
|
||||
if fact.ReplicaId == h.cfg.ReplicaID && !h.assignmentNamesSelf(fact) {
|
||||
h.wd.notPrimary()
|
||||
h.recordOtherLine(fact)
|
||||
|
||||
@@ -583,7 +583,7 @@ Notes:
|
||||
| `INV-LEASE-VIEW-OWNED-001` | The granted deadline and the extender flag exist only in the lease view; refreshing the view from its derive inputs never changes either of them. | M2 every workspace transition | `core/authority/workspace_lease_view.go` `refreshLeaseViewLocked`, `setLeaseDeadlineLocked`, `extendWorkspaceLease` | — | — | STUB |
|
||||
| `INV-WS-LEASE-HORIZON-001` | For the active lease of the current authority epoch, the `Lease.ExpiresAtNS` persisted in the authority store is at least the published horizon, and the published horizon is at least every grant issued since the last reload. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`, `newWorkspaceLease`, `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked`, `issueWorkspaceMove` | `TestWorkspaceLeaseClampsToHorizonUnderStalledStore`, `TestWorkspaceRestartForcedBarrierHonoursHorizon`, `TestWorkspaceAmbiguousExtensionLatchesUncertainty`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardFencesByHorizonUnderStalledStore` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease` | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter` (`core/lifecycle/placement_snapshot_test.go`) | — | ACTIVE |
|
||||
| `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE |
|
||||
| `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE |
|
||||
| `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user