Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

avoid dead lock

Chris Lu53ca7e66ef03
diff --git a/weed/topology/data_node.go b/weed/topology/data_node.go
index ae69534da1..1a0ebf7613 100644
--- a/weed/topology/data_node.go
+++ b/weed/topology/data_node.go
@@ -46,7 +46,7 @@ func (dn *DataNode) getOrCreateDisk(diskType string) *Disk {
c, found := dn.children[NodeId(diskType)]
if !found {
c = NewDisk(diskType)
- dn.LinkChildNode(c)
+ dn.doLinkChildNode(c)
}
disk := c.(*Disk)
return disk
diff --git a/weed/topology/node.go b/weed/topology/node.go
index 25b0484521..f9ac890ef0 100644
--- a/weed/topology/node.go
+++ b/weed/topology/node.go
@@ -210,6 +210,10 @@ func (n *NodeImpl) GetMaxVolumeId() needle.VolumeId {
func (n *NodeImpl) LinkChildNode(node Node) {
n.Lock()
defer n.Unlock()
+ n.doLinkChildNode(node)
+}
+
+func (n *NodeImpl) doLinkChildNode(node Node) {
if n.children[node.Id()] == nil {
n.children[node.Id()] = node
n.UpAdjustDiskUsageDelta(node.GetDiskUsages())