Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled
189 lines
6.5 KiB
Go
189 lines
6.5 KiB
Go
package storage
|
|
|
|
import (
|
|
"sync"
|
|
"unique"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
|
)
|
|
|
|
// volumeReportKey identifies one reported copy. Keyed by disk as well as id
|
|
// because a volume id can be mounted on two disks, and reporting one of them
|
|
// would leave the other's changes untold.
|
|
type volumeReportKey struct {
|
|
diskId uint32
|
|
volumeId uint32
|
|
}
|
|
|
|
// reportedIdentity is what naming a departure needs beyond the volume and disk
|
|
// ids the key already holds. Volumes share very few distinct values here — one
|
|
// per collection, placement, version, ttl and disk type in use — so entries
|
|
// hold a handle to a shared copy, which keeps them small enough that a server
|
|
// with millions of volumes is not paying for identity per volume.
|
|
//
|
|
// The handle is what keeps the shared copy alive, and dropping the last one
|
|
// clears the entry. Handing out the value and letting the handle go, as
|
|
// internVolumeString warns against, would have the next volume make a second
|
|
// copy.
|
|
type reportedIdentity struct {
|
|
collection string
|
|
diskType string
|
|
replicaPlacement uint32
|
|
version uint32
|
|
ttl uint32
|
|
}
|
|
|
|
// reportedVolume is what the master was told about one volume copy: the hash
|
|
// that detects change, the heartbeat pass that last found the copy held, and
|
|
// the identity that names the volume if it departs. The departure message
|
|
// itself is built on the way out, since almost no volume ever leaves.
|
|
type reportedVolume struct {
|
|
hash uint64
|
|
pass uint64
|
|
identity unique.Handle[reportedIdentity]
|
|
}
|
|
|
|
// volumeReportState remembers what the master was last told about each volume,
|
|
// so a heartbeat can carry only what moved since.
|
|
//
|
|
// It is per-connection: a server that reconnects, or reaches a different
|
|
// master, knows nothing about what that master holds and starts again from the
|
|
// full list. The zero value has told no master anything, so it sends the whole
|
|
// list until one accepts changes.
|
|
type volumeReportState struct {
|
|
mu sync.Mutex
|
|
// deltasAccepted is set once the master says it compares digests. Until
|
|
// then the whole list goes every time, which is what an older master needs.
|
|
deltasAccepted bool
|
|
fullListNeeded bool
|
|
// fullListGeneration counts requests for the whole list, so one arriving
|
|
// while a heartbeat is being built is not marked satisfied by it.
|
|
fullListGeneration uint64
|
|
// pass numbers heartbeats, so one can mark the copies it finds held without
|
|
// building a second map of them.
|
|
pass uint64
|
|
lastReported map[volumeReportKey]reportedVolume
|
|
}
|
|
|
|
// reset drops everything known about the master's view.
|
|
func (s *volumeReportState) reset() {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
s.deltasAccepted = false
|
|
s.fullListNeeded = true
|
|
s.fullListGeneration++
|
|
s.lastReported = nil
|
|
}
|
|
|
|
func (s *volumeReportState) acceptDeltas() {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
s.deltasAccepted = true
|
|
}
|
|
|
|
func (s *volumeReportState) requestFullList() {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
s.fullListNeeded = true
|
|
s.fullListGeneration++
|
|
}
|
|
|
|
// begin opens a heartbeat: whether it must carry the whole list, the request it
|
|
// answers, and the pass number that marks the copies it finds still held.
|
|
func (s *volumeReportState) begin() (full bool, generation uint64, pass uint64) {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
s.pass++
|
|
return s.fullListNeeded || !s.deltasAccepted, s.fullListGeneration, s.pass
|
|
}
|
|
|
|
// record marks one volume copy as held by the heartbeat being built, and reports
|
|
// whether the master needs telling about it. It updates the entry already held
|
|
// rather than build a second map beside it, so a server whose volumes are quiet
|
|
// allocates nothing per volume per heartbeat.
|
|
func (s *volumeReportState) record(m *master_pb.VolumeInformationMessage, hash uint64, pass uint64) bool {
|
|
key := volumeReportKey{diskId: m.DiskId, volumeId: m.Id}
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
if previous, known := s.lastReported[key]; known {
|
|
changed := previous.hash != hash
|
|
if changed {
|
|
previous.identity = identityOf(m)
|
|
}
|
|
previous.hash, previous.pass = hash, pass
|
|
s.lastReported[key] = previous
|
|
return changed
|
|
}
|
|
if s.lastReported == nil {
|
|
s.lastReported = make(map[volumeReportKey]reportedVolume)
|
|
}
|
|
s.lastReported[key] = reportedVolume{hash: hash, pass: pass, identity: identityOf(m)}
|
|
return true
|
|
}
|
|
|
|
func identityOf(m *master_pb.VolumeInformationMessage) unique.Handle[reportedIdentity] {
|
|
return unique.Make(reportedIdentity{
|
|
collection: m.Collection,
|
|
diskType: m.DiskType,
|
|
replicaPlacement: m.ReplicaPlacement,
|
|
version: m.Version,
|
|
ttl: m.Ttl,
|
|
})
|
|
}
|
|
|
|
func (held reportedVolume) toShortInformation(key volumeReportKey) *master_pb.VolumeShortInformationMessage {
|
|
identity := held.identity.Value()
|
|
return &master_pb.VolumeShortInformationMessage{
|
|
Id: key.volumeId,
|
|
Collection: identity.collection,
|
|
ReplicaPlacement: identity.replicaPlacement,
|
|
Version: identity.version,
|
|
Ttl: identity.ttl,
|
|
DiskType: identity.diskType,
|
|
DiskId: key.diskId,
|
|
}
|
|
}
|
|
|
|
// commit closes the heartbeat. Copies this pass did not find are forgotten, so
|
|
// one that comes back is reported again, and those whose volume left the server
|
|
// altogether are returned. A delta heartbeat says nothing through silence, so
|
|
// they must be named or the master keeps counting them until a digest mismatch
|
|
// buys it a full list — long enough for a busy cluster to run its free-slot
|
|
// accounting dry. A volume that moved disks is still held, so it is not a
|
|
// departure; a full list is already the whole truth, so it names none.
|
|
func (s *volumeReportState) commit(pass uint64, generation uint64, full bool) []*master_pb.VolumeShortInformationMessage {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
// A request that arrived while this heartbeat was being built asked about a
|
|
// later state than it carries, so it stands.
|
|
if s.fullListGeneration == generation {
|
|
s.fullListNeeded = false
|
|
}
|
|
var goneKeys []volumeReportKey
|
|
for key, prior := range s.lastReported {
|
|
if prior.pass != pass {
|
|
goneKeys = append(goneKeys, key)
|
|
}
|
|
}
|
|
if len(goneKeys) == 0 {
|
|
return nil
|
|
}
|
|
goneIds := make(map[uint32]bool, len(goneKeys))
|
|
for _, key := range goneKeys {
|
|
goneIds[key.volumeId] = true
|
|
}
|
|
for key, prior := range s.lastReported {
|
|
if prior.pass == pass {
|
|
delete(goneIds, key.volumeId)
|
|
}
|
|
}
|
|
var gone []*master_pb.VolumeShortInformationMessage
|
|
for _, key := range goneKeys {
|
|
if !full && goneIds[key.volumeId] {
|
|
gone = append(gone, s.lastReported[key].toShortInformation(key))
|
|
}
|
|
delete(s.lastReported, key)
|
|
}
|
|
return gone
|
|
}
|