|
251 | 251 | end_seq_id %% end_seq_id is exclusive |
252 | 252 | }). |
253 | 253 |
|
254 | | --define(HEADER_GUESS_SIZE, 100). %% see determine_persist_to/2 |
255 | 254 | -define(PERSISTENT_MSG_STORE, msg_store_persistent). |
256 | 255 | -define(TRANSIENT_MSG_STORE, msg_store_transient). |
257 | 256 |
|
@@ -953,7 +952,7 @@ msg_status(IsPersistent, IsDelivered, SeqId, |
953 | 952 | is_delivered = IsDelivered, |
954 | 953 | msg_location = memory, |
955 | 954 | index_on_disk = false, |
956 | | - persist_to = determine_persist_to(Msg, MsgProps, IndexMaxSize), |
| 955 | + persist_to = determine_persist_to(Msg, IndexMaxSize), |
957 | 956 | msg_props = MsgProps}. |
958 | 957 |
|
959 | 958 | beta_msg_status({MsgId, SeqId, MsgLocation, MsgProps, IsPersistent}) |
@@ -1739,33 +1738,13 @@ maybe_write_to_disk(ForceMsg, ForceIndex, MsgStatus, State) -> |
1739 | 1738 | {MsgStatus1, State1} = maybe_write_msg_to_disk(ForceMsg, MsgStatus, State), |
1740 | 1739 | maybe_write_index_to_disk(ForceIndex, MsgStatus1, State1). |
1741 | 1740 |
|
1742 | | -determine_persist_to(Msg, |
1743 | | - #message_properties{size = BodySize}, |
1744 | | - IndexMaxSize) -> |
| 1741 | +determine_persist_to(Msg, IndexMaxSize) -> |
1745 | 1742 | %% The >= is so that you can set the env to 0 and never persist |
1746 | 1743 | %% to the index. |
1747 | | - %% |
1748 | | - %% We want this to be fast, so we avoid size(term_to_binary()) |
1749 | | - %% here, or using the term size estimation from truncate.erl, both |
1750 | | - %% of which are too slow. So instead, if the message body size |
1751 | | - %% goes over the limit then we avoid any other checks. |
1752 | | - %% |
1753 | | - %% If it doesn't we need to decide if the properties will push |
1754 | | - %% it past the limit. If we have the encoded properties (usual |
1755 | | - %% case) we can just check their size. If we don't (message came |
1756 | | - %% via the direct client), we make a guess based on the number of |
1757 | | - %% headers. |
1758 | | - |
1759 | | - %% @todo We can probably simplify this. |
1760 | | - {MetaSize, _BodySize} = mc:size(Msg), |
1761 | | - case BodySize >= IndexMaxSize of |
| 1744 | + {MetaSize, BodySize} = mc:size(Msg), |
| 1745 | + case MetaSize + BodySize >= IndexMaxSize of |
1762 | 1746 | true -> msg_store; |
1763 | | - false -> |
1764 | | - Est = MetaSize + BodySize, |
1765 | | - case Est >= IndexMaxSize of |
1766 | | - true -> msg_store; |
1767 | | - false -> queue_store |
1768 | | - end |
| 1747 | + false -> queue_store |
1769 | 1748 | end. |
1770 | 1749 |
|
1771 | 1750 | persist_to(#msg_status{persist_to = To}) -> To. |
|
0 commit comments