VGalaxies commented on code in PR #3049:
URL: https://github.com/apache/hugegraph/pull/3049#discussion_r3400876567
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BytesBuffer.java:
##########
@@ -122,6 +126,40 @@ public static BytesBuffer wrap(byte[] array, int offset,
int length) {
return new BytesBuffer(ByteBuffer.wrap(array, offset, length));
}
+ public static int maxBufferCapacity() {
+ Integer capacity = maxBufferCapacity;
+ return capacity != null ? capacity : MAX_BUFFER_CAPACITY;
+ }
+
+ public static synchronized void initMaxBufferCapacity(int capacity) {
+ E.checkArgument(capacity >= DEFAULT_CAPACITY &&
+ capacity <= MAX_BUFFER_CAPACITY_UPPER_BOUND,
+ "Max buffer capacity must be in range [%s, %s], " +
+ "but got %s",
+ DEFAULT_CAPACITY, MAX_BUFFER_CAPACITY_UPPER_BOUND,
+ capacity);
+
+ if (maxBufferCapacity == null) {
Review Comment:
**High: Default config can block later explicit buffer cap**
`hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BytesBuffer.java:142`
**Evidence**
- `StandardHugeGraph` initializes `BytesBuffer` for every graph using
`config.get(CoreOptions.SERIALIZER_BUFFER_MAX_CAPACITY)`, whose default is
`BytesBuffer.MAX_BUFFER_CAPACITY`. `initMaxBufferCapacity()` stores the first
value unconditionally when `maxBufferCapacity == null`, and only treats
`MAX_BUFFER_CAPACITY` as inherit on later calls. Therefore a default graph
opened first fixes the process-wide value at 128 MiB, and a later graph
explicitly setting 256 MiB hits the conflict path.
**Impact**
- Multi-graph deployments can succeed or fail based on graph load order; a
graph with a valid explicit `serializer.buffer_max_capacity` may fail to load
after any graph that omitted the option.
**Requested fix**
- Distinguish omitted/default values from explicit configuration before
initializing the process-wide cap, or validate/select the single process-wide
value before opening graphs. Add coverage for default-first then custom-second
graph initialization.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]