Description
In #42489 we introduced a new layout for the data directory, but this does not today play nicely with some corner cases of upgrades and downgrades.
Firstly, as noted in #44624 (comment), we reorganise the data directory before checking that we can load and upgrade the cluster metadata; if it turns out that the cluster metadata is unreadable and needs fixing in 7.x then the user is stuck since a downgrade to 7.x will not find the cluster metadata since was already moved. I think we should not reorganise the data directory until we are sure that the upgraded node is viable.
Secondly, if a user does try and downgrade an 8.x node to 7.x then the node will successfully start up but will appear to be completely empty since the upgrade to 8.x already reorganised the data directory. I think we should protect against this by, for instance, leaving a copy of the node metadata in place in nodes/0/_state
to indicate that this node has been upgraded.