{"record":{"id":"75b54ea51c59c6db","repo":"MyCATApache/Mycat-Server","slug":"page-size-pagesizebytes-cannot-exceed-maxpage","errorCode":null,"errorMessage":"Page size ${pageSizeBytes} cannot exceed ${maxPageSizeBytes}","messagePattern":"Page size (.+?) cannot exceed (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/memory/unsafe/map/BytesToBytesMap.java","lineNumber":200,"sourceCode":"      long pageSizeBytes,\n      boolean enablePerfMetrics) {\n    super(dataNodeMemoryManager, pageSizeBytes);\n    this.dataNodeMemoryManager = dataNodeMemoryManager;\n    this.blockManager = blockManager;\n    this.serializerManager = serializerManager;\n    this.loadFactor = loadFactor;\n    this.loc = new Location();\n    this.pageSizeBytes = pageSizeBytes;\n    this.enablePerfMetrics = enablePerfMetrics;\n    if (initialCapacity <= 0) {\n      throw new IllegalArgumentException(\"Initial capacity must be greater than 0\");\n    }\n    if (initialCapacity > MAX_CAPACITY) {\n      throw new IllegalArgumentException(\n        \"Initial capacity \" + initialCapacity + \" exceeds maximum capacity of \" + MAX_CAPACITY);\n    }\n    if (pageSizeBytes > DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES) {\n      throw new IllegalArgumentException(\"Page size \" + pageSizeBytes + \" cannot exceed \" +\n        DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES);\n    }\n    allocate(initialCapacity);\n  }\n\n  public BytesToBytesMap(\n      DataNodeMemoryManager dataNodeMemoryManager,\n      int initialCapacity,\n      long pageSizeBytes) {\n    this(dataNodeMemoryManager, initialCapacity, pageSizeBytes, false);\n  }\n\n  public BytesToBytesMap(\n      DataNodeMemoryManager dataNodeMemoryManager,\n      int initialCapacity,\n      long pageSizeBytes,\n      boolean enablePerfMetrics) {\n    this(","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/memory/unsafe/map/BytesToBytesMap.java#L182-L218","documentation":"BytesToBytesMap's constructor validates that pageSizeBytes does not exceed DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES. Pages are allocated as contiguous memory blocks, so a page larger than the maximum supported size cannot be allocated and the constructor fails fast with an IllegalArgumentException.","triggerScenarios":"Calling `new BytesToBytesMap(...)` with a pageSizeBytes argument greater than DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES.","commonSituations":"Tuning a page-size config value to something like 2GB or a machine's full RAM assuming larger pages are always better; unit mistakes (writing bytes where MB was intended, e.g. 17179869184 instead of 16MB).","solutions":["Lower pageSizeBytes to at most DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES (typically tens of MB is sufficient).","Check the config property supplying the page size for unit conversion mistakes.","Clamp before construction: `pageSizeBytes = Math.min(pageSizeBytes, DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES)`.","If larger per-record storage is needed, increase the number of pages rather than the page size."],"exampleFix":"// before\nBytesToBytesMap map = new BytesToBytesMap(\n    memoryManager, allocator, 1024, 4L * 1024 * 1024 * 1024, false); // 4GB page\n// after\nlong pageSizeBytes = Math.min(4L * 1024 * 1024 * 1024,\n    DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES);\nBytesToBytesMap map = new BytesToBytesMap(\n    memoryManager, allocator, 1024, pageSizeBytes, false);","handlingStrategy":"validation","validationCode":"if (pageSizeBytes > DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES) {\n  pageSizeBytes = DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES;\n}\nBytesToBytesMap map = new BytesToBytesMap(mm, allocator, initialCapacity, pageSizeBytes, metrics);","typeGuard":null,"tryCatchPattern":"try {\n  map = new BytesToBytesMap(mm, allocator, initialCapacity, pageSizeBytes, metrics);\n} catch (IllegalArgumentException e) {\n  map = new BytesToBytesMap(mm, allocator, initialCapacity,\n      DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES, metrics);\n}","preventionTips":["Clamp pageSizeBytes to DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES.","Double-check units in page-size configs (bytes vs MB).","Prefer more/smaller pages over one giant page.","Share a single validated page-size constant across the codebase."],"tags":["java","memory","illegal-argument","configuration"],"backgroundTag":"value-out-of-range","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}