rundood5 opened a new pull request, #11559:
URL: https://github.com/apache/rocketmq/pull/11559

   ### Motivation
   
   When the commitlog volume goes above the disk threshold, the broker marks 
the message store
   read-only and producers fail with `CODE: 14 DESC: service not available 
now`. Diagnosing it is
   harder than it should be, for three reasons:
   
   1. `broker.log` only prints the raw bit value:
      `message store is not writeable, so putMessage is forbidden 16`.
      `16` is `RunningFlags.DISK_FULL_BIT = 1 << 4`, but nothing in the log 
says so.
   2. `store.log` prints the measured ratio without the effective threshold, so 
an operator cannot
      tell how far the volume is from the limit.
   3. `diskSpaceWarningLevelRatio` is silently clamped to `[0.35, 0.90]`. 
Configuring `0.97` neither
      fails nor warns, so an operator may believe the new value is in effect; 
`diskMaxUsedSpaceRatio`
      does not take part in this check at all.
   
   The first check runs 60 seconds after the store starts, which makes the 
failure look intermittent:
   a freshly started broker accepts writes for about a minute and then starts 
rejecting them.
   
   ### Modification
   
   - `RunningFlags`: add `getFlagBitsString()`, which renders the current bits 
as readable names
     (`DISK_FULL`, `NOT_READABLE|DISK_FULL`, ...) and returns `NONE` when no 
bit is set.
     `getFlagBits()` is unchanged.
   - `HookUtils#checkBeforePutMessage`: log the numeric value together with the 
names, so existing
     greps and dashboards that match the number keep working:
     `... forbidden, flagBits=16, flags=DISK_FULL`.
   - `DefaultMessageStore.CleanCommitLogService`: log once when the configured
     `diskSpaceWarningLevelRatio` falls outside the allowed range, including 
the range and the
     effective value; append the effective threshold to the "physic disk maybe 
full soon" message.
   - Add `RunningFlagsTest` covering the empty, single, multiple and cleared 
cases.
   
   No behaviour change: the clamp produces exactly the same values as before 
(the two `if`
   statements are replaced by an equivalent `Math.min`/`Math.max`), and only 
log output plus a new
   accessor are added.
   
   ### Verification
   
   - `mvn -o -pl store,broker -am -DskipTests compile` — BUILD SUCCESS 
(checkstyle included).
   - `mvn -o -pl store -Dtest=RunningFlagsTest test` — Tests run: 4, Failures: 
0, Errors: 0.
   
   End-to-end on two brokers running side by side on the same host, both under 
disk pressure
   (96%+ used).
   
   Before (unmodified broker):
   
   ```
   WARN SendMessageThread_1 - message store is not writeable, so putMessage is 
forbidden 16
   ```
   
   After (this branch):
   
   ```
   WARN SendMessageThread_1 - message store is not writeable, so putMessage is 
forbidden, flagBits=16, flags=DISK_FULL
   ```
   
   Store log after the change:
   
   ```
   ERROR StoreScheduledThread1 - physic disk maybe full soon 0.97, so mark disk 
full, storePathPhysic=./devenv-verify/store/commitlog, 
diskSpaceWarningLevelRatio=0.9
   ```


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