{"record":{"id":"c9cc4dcfe7e6ea82","repo":"pinpoint-apm/pinpoint","slug":"numregions-must-be-greater-than-1","errorCode":null,"errorMessage":"numRegions must be greater than 1","messagePattern":"numRegions must be greater than 1","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/reader/core/CreateTableChange.java","lineNumber":110,"sourceCode":"            public String toString() {\n                return \"Manual{\" +\n                        \"splitKeys=\" + splitKeys +\n                        '}';\n            }\n        }\n\n        // Implementation copied from hbase's RegionSplitter$UniformSplit\n        // https://github.com/apache/hbase/blob/master/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java\n        class Auto implements SplitOption {\n            private static final byte xFF = (byte) 0xFF;\n            private static final byte[] FIRST_ROW_BYTES = EMPTY_BYTE_ARRAY;\n            private static final byte[] LAST_ROW_BYTES = new byte[]{xFF, xFF, xFF, xFF, xFF, xFF, xFF, xFF};\n\n            private final int numRegions;\n\n            public Auto(int numRegions) {\n                if (!(numRegions > 1)) {\n                    throw new IllegalArgumentException(\"numRegions must be greater than 1\");\n                }\n                this.numRegions = numRegions;\n\n            }\n\n            @Override\n            public byte[][] getSplitKeys() {\n                return generateSplitKeys();\n            }\n\n            private byte[][] generateSplitKeys() {\n                byte[][] splits = Bytes.split(FIRST_ROW_BYTES, LAST_ROW_BYTES, true, numRegions - 1);\n                // remove endpoints, which are included in the splits list\n                if (splits == null) {\n                    throw new IllegalStateException(\"Could not generate split keys, numRegions : \" + numRegions);\n                }\n                return Arrays.copyOfRange(splits, 1, splits.length - 1);\n            }","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/reader/core/CreateTableChange.java#L92-L128","documentation":"The Auto SplitOption requires numRegions > 1 because auto-splitting uses a predefined start/end row range (including LAST_ROW_BYTES) to compute region boundaries; one region means no split is needed and the math breaks. Values <= 1 are rejected at construction.","triggerScenarios":"Calling new CreateTableChange.SplitOption.Auto(1), Auto(0), or a negative value when defining a CreateTableChange with automatic region splitting.","commonSituations":"numRegions read from configuration where the default is 0 or 1; a sizing script that returned 1 region for a small table; misunderstanding that Auto(N) creates N regions so N must exceed 1.","solutions":["Pass numRegions >= 2 to Auto(...)","Use the Manual(splitKeys) option when you need exactly one boundary key or explicit control","For an unsplit table, use the no-split option instead of Auto","Fix the config value feeding numRegions and validate it before constructing"],"exampleFix":"// before\nSplitOption option = new SplitOption.Auto(1);\n// after\nSplitOption option = new SplitOption.Auto(8);","handlingStrategy":"validation","validationCode":"if (numRegions <= 1) {\n    throw new IllegalArgumentException(\"numRegions must be > 1\");\n}\nnew CreateTableChange.SplitOption.Auto(numRegions);","typeGuard":"boolean isValidRegionCount(int n) {\n    return n > 1;\n}","tryCatchPattern":"try {\n    SplitOption opt = new CreateTableChange.SplitOption.Auto(numRegions);\n} catch (IllegalArgumentException e) {\n    // clamp to a valid default\n    opt = new CreateTableChange.SplitOption.Auto(8);\n}","preventionTips":["Validate config values feeding numRegions (must be >= 2)","Remember Auto(N) creates N regions; 1 region means no split — use no-split instead","Add unit tests for split-option construction with edge values 0 and 1"],"tags":["hbase","schema","num-regions","illegal-argument"],"backgroundTag":"argument-out-of-range","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}