{"record":{"id":"7951ac59106a129e","repo":"aeron-io/aeron","slug":"filepagesize-not-a-power-of-2-pagesize","errorCode":null,"errorMessage":"filePageSize not a power of 2: ${pageSize}","messagePattern":"filePageSize not a power of 2: (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"aeron-driver/src/main/java/io/aeron/driver/Configuration.java","lineNumber":2549,"sourceCode":"            throw new ConfigurationException(\n                \"initialWindowLength=\" + ctx.initialWindowLength() + \" > SO_RCVBUF=\" + soRcvBuf +\n                \", increase \" + SOCKET_RCVBUF_LENGTH_PROP_NAME + \" limits to match initialWindowLength\");\n        }\n    }\n\n    /**\n     * Validate that page size is valid and alignment is valid.\n     *\n     * @param pageSize to be checked.\n     * @throws ConfigurationException if the size is not as expected.\n     */\n    public static void validatePageSize(final int pageSize)\n    {\n        validateValueRange(pageSize, PAGE_MIN_SIZE, PAGE_MAX_SIZE, \"filePageSize\");\n\n        if (!BitUtil.isPowerOfTwo(pageSize))\n        {\n            throw new ConfigurationException(\"filePageSize not a power of 2: \" + pageSize);\n        }\n    }\n\n    /**\n     * Validate the range of session ids based on a high and low value provided which accounts for the values wrapping.\n     *\n     * @param low  value in the range.\n     * @param high value in the range.\n     * @throws ConfigurationException if the values are not valid.\n     */\n    public static void validateSessionIdRange(final int low, final int high)\n    {\n        if (low > high)\n        {\n            throw new ConfigurationException(\"low session id value \" + low + \" must be <= high value \" + high);\n        }\n\n        if (Math.abs((long)high - low) > Integer.MAX_VALUE)","sourceCodeStart":2531,"sourceCodeEnd":2567,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-driver/src/main/java/io/aeron/driver/Configuration.java#L2531-L2567","documentation":"Aeron maps term buffers and log files in fixed-size pages, so the file page size must be a power of two (and within PAGE_MIN_SIZE..PAGE_MAX_SIZE, 64KB..1GB by default). Configuration.validatePageSize throws this ConfigurationException when BitUtil.isPowerOfTwo(pageSize) is false. Non-power-of-two pages would break the bit-mask based page index arithmetic used throughout the log buffer code.","triggerScenarios":"Calling Configuration.validatePageSize (via DriverContext.filePageSize / LogBufferAddressManager use) with a value like 100000, 3MB, or any non-2^N value, or a value outside the allowed min/max range.","commonSituations":"Trying to match a filesystem or device block size that is not a power of two; hand-computing '4MB-ish' values; misunit conversions (e.g. 10485760 for '10MB').","solutions":["Set aeron.file.page.size (or ctx.filePageSize) to a power of two, e.g. 1 << 20 (1MB) or 4MB","Use BitUtil.findNextPositivePowerOfTwo(desired) to round the value before setting it","Keep the value within PAGE_MIN_SIZE (64KB) and PAGE_MAX_SIZE (1GB)"],"exampleFix":"// before\nctx.filePageSize(3 * 1024 * 1024);\n// after\nctx.filePageSize(1 << 22); // 4MB, power of two","handlingStrategy":"validation","validationCode":"int pageSize = Integer.getInteger(\"aeron.file.page.size\", 1 << 20);\nif (Integer.bitCount(pageSize) != 1) {\n    pageSize = Integer.highestOneBit(pageSize) << 1; // round up to power of two\n}\nio.aeron.driver.Configuration.validatePageSize(pageSize);","typeGuard":null,"tryCatchPattern":"try {\n    ctx.filePageSize(requested);\n    ctx.conclude();\n} catch (ConfigurationException e) {\n    ctx.filePageSize(1 << 20); // default 1MB\n    ctx.conclude();\n}","preventionTips":["Only use power-of-two page sizes (64KB..1GB allowed range)","Round with BitUtil.findNextPositivePowerOfTwo before setting","Unit-test any config that derives page size from external input"],"tags":["aeron","configuration","page-size","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}