vitessio/vitess · error
len(p.Patch)%3
Error message
len(p.Patch)%3
What it means
Layout_uca900.allocPage validates that each Patch's Patch slice length is a multiple of 3 (primary, secondary, tertiary weights per collation element). A non-multiple-of-3 patch means the patch data is malformed. This is a startup/initialization-time panic protecting the generated collation tables.
Source
Thrown at go/mysql/collations/internal/uca/layout.go:137
return nil
}
ceCount := int((*page)[offset])
for ce := range ceCount {
result = append(result,
(*page)[256+(ce*3+0)*256+offset],
(*page)[256+(ce*3+1)*256+offset],
(*page)[256+(ce*3+2)*256+offset],
)
}
return
}
func (Layout_uca900) allocPage(original *[]uint16, patches []Patch) []uint16 {
var maxWeights int
for _, p := range patches {
if len(p.Patch)%3 != 0 {
panic("len(p.Patch)%3")
}
if len(p.Patch) > maxWeights {
maxWeights = len(p.Patch)
}
}
minLenForPage := maxWeights*CodepointsPerPage + CodepointsPerPage
if original == nil {
return make([]uint16, minLenForPage)
}
if len(*original) > minLenForPage {
minLenForPage = len(*original)
}
newPage := make([]uint16, minLenForPage)
copy(newPage, *original)
return newPage
}
View on GitHub (pinned to 01a25a7d17)
Solutions
- Fix the patch data so each entry has exactly 3 uint16s per collation element (primary, secondary, tertiary)
- Regenerate collation tables via the codegen pipeline instead of editing generated files
- Restore the original generated colldata files from a clean checkout
Defensive patterns
Strategy: validation
Validate before calling
for _, p := range patches {
if len(p.Patch)%3 != 0 {
return fmt.Errorf("patch %q has invalid weight length %d", p.Prefix, len(p.Patch))
}
} Prevention
- Define patches only through the codegen pipeline
- Keep each patch entry as complete primary/secondary/tertiary triples
- Restore generated colldata files instead of editing them
When it happens
Trigger: Building or regenerating UCA 900 collation pages with patch data whose []uint16 length is not divisible by 3 — i.e. a malformed entry in the collation patch tables (colldata generated files).
Common situations: Editing go/mysql/collations generated data by hand; custom collation development where patch definitions were typed incorrectly.
Related errors
- WeightStringLen called with non-MOD4 length
- unreachable
- bad literal argument
- '%n' directive requires a slice
- slow path for `n` directive for slice of type other than Exp
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/1384211c527963c2.
Report an issue: GitHub.