Skip to content

Commit 7926d1c

Browse files
lukebakkenthe-mikedavis
authored andcommitted
rabbit_disk_monitor: Document NaN alarm behavior
When disk information is unavailable, the 'available' field in mount records is set to 'NaN'. Due to Erlang term ordering, 'NaN' < Limit evaluates to true, which triggers alarms for those mounts. This is correct fail-safe behavior - when we cannot determine available disk space, we block publishing to prevent potential disk exhaustion. Add comments to alarmed_mounts/1 and alarmed_queue_types/1 explaining this intentional behavior.
1 parent 31a7508 commit 7926d1c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

deps/rabbit/src/rabbit_disk_monitor.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ alarmed_mounts(Mounts) ->
385385
maps:fold(
386386
fun (Path, #mount{available = Available,
387387
limit = Limit}, Acc) when Available < Limit ->
388+
%% Note: 'NaN' < Limit is true (Erlang term ordering), which is
389+
%% correct fail-safe behavior when disk info is unavailable
388390
sets:add_element(Path, Acc);
389391
(_Path, _Mount, Acc) ->
390392
Acc
@@ -397,6 +399,8 @@ alarmed_queue_types(MountPoints) ->
397399
fun (_Path, #mount{available = Available,
398400
limit = Limit,
399401
queue_types = QTs}, Acc) when Available < Limit ->
402+
%% Note: 'NaN' < Limit is true (Erlang term ordering), which is
403+
%% correct fail-safe behavior when disk info is unavailable
400404
sets:union(QTs, Acc);
401405
(_Path, _Mount, Acc) ->
402406
Acc

0 commit comments

Comments
 (0)