guyinyou opened a new issue, #9693:
URL: https://github.com/apache/rocketmq/issues/9693

   ### Before Creating the Enhancement Request
   
   - [x] I have confirmed that this should be classified as an enhancement 
rather than a bug/feature.
   
   
   ### Summary
   
   Add a new writeWithoutMmap configuration option that allows RocketMQ to use 
RandomAccessFile for writing operations instead of MappedByteBuffer. This 
enhancement addresses a critical issue where JVM crashes occur when the 
underlying storage device suddenly becomes read-only, as MappedByteBuffer write 
operations cannot handle this scenario gracefully.
   
   ### Motivation
   
   The current implementation relies on MappedByteBuffer for write operations, 
which can cause JVM crashes in specific scenarios:
   Device read-only transitions: When storage devices suddenly become read-only 
(due to hardware issues, filesystem remounts, or other system-level changes), 
MappedByteBuffer write operations cause JVM crashes instead of graceful error 
handling
   System stability: JVM crashes in production environments can lead to data 
loss and service unavailability
   Error handling: RandomAccessFile provides better error handling capabilities 
for write operations when encountering read-only filesystem conditions
   Production reliability: Critical systems need robust error handling 
mechanisms to maintain service availability
   This enhancement benefits the project by:
   Preventing JVM crashes in production environments
   Providing graceful error handling when storage becomes read-only
   Maintaining system stability during hardware or filesystem issues
   Offering a fallback mechanism for critical write operations
   
   
   ### Describe the Solution You'd Like
   
   The enhancement involves:
   Configuration Addition: Add writeWithoutMmap boolean flag to 
MessageStoreConfig
   DefaultMappedFile Enhancement: Modify DefaultMappedFile to support both I/O 
modes:
   When writeWithoutMmap = false (default): Use MappedByteBuffer for both read 
and write operations
   When writeWithoutMmap = true: Use RandomAccessFile for writing, 
MappedByteBuffer for reading
   Write Operations: Update all write methods to use RandomAccessFile when 
writeWithoutMmap = true
   Error Handling: Implement proper error handling that can gracefully handle 
read-only filesystem conditions
   Resource Management: Ensure proper cleanup and error reporting in both modes
   
   
   ### Describe Alternatives You've Considered
   
   Exception handling around MappedByteBuffer: This would not prevent JVM 
crashes as the issue occurs at the JVM level
   Filesystem monitoring: Adding monitoring to detect read-only transitions 
would add complexity without solving the core issue
   Complete removal of MappedByteBuffer: This would break backward 
compatibility and remove performance benefits for read operations
   Runtime detection: Attempting to detect read-only conditions at runtime 
would be unreliable and add overhead
   The chosen solution provides the best balance of crash prevention, 
performance, and maintainability while preserving backward compatibility.
   
   ### Additional Context
   
   _No response_


-- 
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]

Reply via email to