sijie commented on a change in pull request #1755: Configure Netty allocator in bookie and client URL: https://github.com/apache/bookkeeper/pull/1755#discussion_r228748144
########## File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java ########## @@ -634,6 +639,21 @@ public Bookie(ServerConfiguration conf, StatsLogger statsLogger) this.indexDirsManager = createIndexDirsManager(conf, diskChecker, statsLogger.scope(LD_INDEX_SCOPE), this.ledgerDirsManager); + this.allocator = ByteBufAllocatorBuilder.create() + .poolingPolicy(conf.getAllocatorPoolingPolicy()) + .poolingConcurrency(conf.getAllocatorPoolingConcurrency()) + .outOfMemoryPolicy(conf.getAllocatorOutOfMemoryPolicy()) + .outOfMemoryListener((ex) -> { + try { + LOG.error("Unable to allocate memory, exiting bookie", ex); + shutdown(-1); + } finally { + Runtime.getRuntime().halt(-1); Review comment: @merlimat there is an `uncaughtExceptionHandler` in bookie server (https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java#L78). There are two approaches: 1) pass the uncaught exception handler down from bookie server to bookie. so that bookie can trigger uncaught exception handler when OOM 2) construct the allocator outside of bookie instance. so when the allocator is constructed in bookie server, it can use the uncaught exception handler when OOM ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services