MyCATApache/Mycat-Server · error · IllegalArgumentException
Cannot allocate a page with more than
Error message
Cannot allocate a page with more than ${maxPageSizeBytes} bytes What it means
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.
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.
Example fix
// before
MemoryBlock page = memoryManager.allocatePage(recordSize * 4096, consumer);
// after
long size = Math.min(recordSize * 4096,
DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES);
MemoryBlock page = memoryManager.allocatePage(size, consumer); Defensive patterns
Strategy: validation
Validate before calling
if (size > DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES) {
size = DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES;
}
MemoryBlock page = memoryManager.allocatePage(size, consumer); Try / catch
try {
page = memoryManager.allocatePage(size, consumer);
} catch (IllegalArgumentException e) {
page = memoryManager.allocatePage(
DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES, consumer);
} Prevention
- 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.
When it happens
Trigger: Calling `memoryManager.allocatePage(size, consumer)` (directly or via MemoryConsumer.allocatePage/allocateArray paths) with size > DataNodeMemoryManager.MAXIMUM_PAGE_SIZE_BYTES.
Common situations: 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.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Initial capacity exceeds maximum capacity of
- Page size cannot exceed
- error while calling spill() on
- error while calling spill() on
- Have already allocated a maximum of
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/fb748a94db96f0a2.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/memory/unsafe/memory/mm/DataNodeMemoryManager.java:230
}
/**
* Return the page size in bytes.
*/
public long pageSizeBytes() {
return memoryManager.pageSizeBytes();
}
/**
* Allocate a block of memory that will be tracked in the MemoryManager's page table; this is
* intended for allocating large blocks of Tungsten memory that will be shared between operators.
*
* Returns `null` if there was not enough memory to allocate the page. May return a page that
* contains fewer bytes than requested, so callers should verify the size of returned pages.
*/
public MemoryBlock allocatePage(long size, MemoryConsumer consumer) {
if (size > MAXIMUM_PAGE_SIZE_BYTES) {
throw new IllegalArgumentException(
"Cannot allocate a page with more than " + MAXIMUM_PAGE_SIZE_BYTES + " bytes");
}
/**
* 这里spill到磁盘中,释放内存空间
*/
long acquired = 0;
try {
acquired = acquireExecutionMemory(size,tungstenMemoryMode, consumer);
} catch (InterruptedException e) {
logger.error(e.getMessage());
}
if (acquired <= 0) {
return null;
}
final int pageNumber;View on GitHub (pinned to 65f8d8beb7)