Communication apparatus includes a hierarchical network of switches, which includes at least a first plurality of spine switches, interconnected by a control channel, and a second plurality of edge switches having internal ports coupled to communicate via respective links with the spine switches and external ports for connecting to client devices. The spine switches are configured to detect, via the control channel, a partitioning of the hierarchical network into first and second partitions, including respective first and second numbers of the spine switches, wherein the first number is greater than the second number, and to assign respective priorities to the spine switches responsively to the first and second numbers so as to cause the larger of the partitions to be elected as a spanning tree root.