{"record":{"id":"fb748a94db96f0a2","repo":"MyCATApache/Mycat-Server","slug":"cannot-allocate-a-page-with-more-than-maxpagesiz","errorCode":null,"errorMessage":"Cannot allocate a page with more than ${maxPageSizeBytes} bytes","messagePattern":"Cannot allocate a page with more than (.+?) bytes","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/memory/unsafe/memory/mm/DataNodeMemoryManager.java","lineNumber":230,"sourceCode":"  }\n\n  /**\n   * Return the page size in bytes.\n   */\n  public long pageSizeBytes() {\n    return memoryManager.pageSizeBytes();\n  }\n\n  /**\n   * Allocate a block of memory that will be tracked in the MemoryManager's page table; this is\n   * intended for allocating large blocks of Tungsten memory that will be shared between operators.\n   *\n   * Returns `null` if there was not enough memory to allocate the page. May return a page that\n   * contains fewer bytes than requested, so callers should verify the size of returned pages.\n   */\n  public MemoryBlock allocatePage(long size, MemoryConsumer consumer) {\n    if (size > MAXIMUM_PAGE_SIZE_BYTES) {\n      throw new IllegalArgumentException(\n        \"Cannot allocate a page with more than \" + MAXIMUM_PAGE_SIZE_BYTES + \" bytes\");\n    }\n\n    /**\n     * 这里spill到磁盘中，释放内存空间\n     */\n    long acquired = 0;\n    try {\n      acquired = acquireExecutionMemory(size,tungstenMemoryMode, consumer);\n    } catch (InterruptedException e) {\n      logger.error(e.getMessage());\n    }\n\n    if (acquired <= 0) {\n      return null;\n    }\n\n    final int pageNumber;","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/memory/unsafe/memory/mm/DataNodeMemoryManager.java#L212-L248","documentation":"DataNodeMemoryManager.allocatePage validates that the requested page size does not exceed MAXIMUM_PAGE_SIZE_BYTES before acquiring memory. Larger pages cannot be backed by a single contiguous memory block, so it throws IllegalArgumentException immediately.","triggerScenarios":"Calling `memoryManager.allocatePage(size, consumer)` (directly or via MemoryConsumer.allocatePage/allocateArray paths) with size > DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES.","commonSituations":"Computing page size from record sizes that exceed the cap (e.g. one giant row dictating page size); misconfigured page-size property with wrong units; copying a page-size setting from a system with a larger limit.","solutions":["Reduce the requested page size to <= MAXIMUM_PAGE_SIZE_BYTES.","Clamp before calling: `size = Math.min(size, DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES)`.","Handle oversized records separately (external/chunked storage) instead of sizing a page to fit one record.","Fix the page-size configuration value if it was entered with wrong units."],"exampleFix":"// before\nMemoryBlock page = memoryManager.allocatePage(recordSize * 4096, consumer);\n// after\nlong size = Math.min(recordSize * 4096,\n    DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES);\nMemoryBlock page = memoryManager.allocatePage(size, consumer);","handlingStrategy":"validation","validationCode":"if (size > DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES) {\n  size = DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES;\n}\nMemoryBlock page = memoryManager.allocatePage(size, consumer);","typeGuard":null,"tryCatchPattern":"try {\n  page = memoryManager.allocatePage(size, consumer);\n} catch (IllegalArgumentException e) {\n  page = memoryManager.allocatePage(\n      DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES, consumer);\n}","preventionTips":["Clamp page-size requests to MAXIMUM_PAGE_SIZE_BYTES.","Handle records larger than a page with chunked/external storage.","Validate page-size config values at load time.","Reuse pages instead of resizing upward repeatedly."],"tags":["java","memory","illegal-argument","page-size"],"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"}