-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix possible wrong merging after ATTACH PART for Collapsing and Repla…
…cing engines without version, look ClickHouse/ClickHouse#71009 for details Signed-off-by: Slach <[email protected]>
- Loading branch information
Showing
3 changed files
with
25 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package metadata | ||
|
||
import ( | ||
"sort" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// SortPartsByMinBlock need to avoid wrong restore for Replacing, Collapsing, https://github.com/ClickHouse/ClickHouse/issues/71009 | ||
func SortPartsByMinBlock(parts []Part) { | ||
sort.Slice(parts, func(i, j int) bool { | ||
namePartsI := strings.Split(parts[i].Name, "_") | ||
namePartsJ := strings.Split(parts[j].Name, "_") | ||
// partitions different | ||
if namePartsI[0] != namePartsJ[0] { | ||
return namePartsI[0] < namePartsJ[0] | ||
} | ||
// partition same, min block | ||
minBlockI, _ := strconv.Atoi(namePartsI[1]) | ||
minBlockJ, _ := strconv.Atoi(namePartsJ[1]) | ||
return minBlockI < minBlockJ | ||
}) | ||
} |