4 ms·
If you use a message hash as your unique identifier for exactly-once delivery, your messaging system won't let a user send the same message twice, even if they
by haberman 11y ago
If you use a message hash as your unique identifier for exactly-once delivery, your messaging system won't let a user send the same message twice, even if they mean to.
You could wrap the user's message in some metadata including a uuid to ensure the overall content is distinct from anytime the user previously posted that message. But now you're back at uuids, which you say you don't like.
- redka 11y agoA counter solves this without UUID
- ketralnis 11y agoCounters have a host of other problems, like making sure that you never issue the same counter twice in a system without a central authority (or just one that doesn't desire a single point of failure)
- btrask 11y agoYou need to think about what makes messages distinct. Content addressing will help you as long as you have a rigorous definition of identity, which you might otherwise be doing ad-hoc when you assign UUIDs. If the same message is meaningful at different points in time, your hashed content should include a timestamp (and of course you need to choose an appropriate level of precision). If your message is meaningful in different contents, it needs to reference that context somehow (ideally by hash). The payoff for doing this well is 1. an elimination of double-sent emails, double-posts, etc. (when the software might not know if it went through the first time), and 2. the ability to deduplicate across a network partition, for example if a user makes the same change on their computer and on their phone and then syncs them.
- zAy0LfpBZLC8mAC 11y ago... except wallclock timestamps for ordering of events in a distributed system is a terrible idea in most cases for the simple reason that (a) it's not a (even close to) guaranteed unique event identifier (the same time happens in many locations), (b) you usually don't have a clock of sufficient precision to even reliably establish a total order of distinct moments and (c) even if you have, that order does not necessarily preserve causality. Now, UUIDs don't solve (b) or (c) either, but at least they actually give you a reliable identifier for events.
- btrask 11y agoNo one is talking about ordering events.
- schrodinger 11y agoPretty sure messages are ordered events in this scenario, no?
- btrask 11y agoThey're events, but no ordering is assumed, guaranteed, promised, implied, or enforced. The timestamps, if you choose to use them, are only for determining message identity (equality) and thus can be as accurate or inaccurate as relevant for your application. You don't have to use timestamps if they don't make sense. For example, what is the "identity" of a message in an instant messaging program? If you just use the message content, then duplicate messages don't work. It would make sense to include the sender and the time written (which is different from the time sent!) as well. You might also include the recipient, depending. Note that instead of using timestamps, you could use the hash of the message being replied to. However, IM software usually doesn't have a system for real replies, so doing that properly probably isn't worthwhile. (Edit: however, hashes are very useful for systems like email, forums, etc., where reply targets are explicitly defined.) If you do want ordering, BYO. Content addressing and UUIDs are equivalent in that regard.
- zAy0LfpBZLC8mAC 11y ago> The timestamps, if you choose to use them, are only for determining message identity (equality) Which simply doesn't work because timestamps are not unique to location. Every clock experiences every timestamp, and thus potentially assigns any timestamp to an event, so multiple clocks can end up assigning the same timestamp to distinct events, and thus identifying them. > Note that instead of using timestamps, you could use the hash of the message being replied to. If your message isn't unique, the message you are replying to probably isn't either, so it's useless to use it as an identifier. > If you do want ordering, BYO. Content addressing and UUIDs are equivalent in that regard. No, they are not, at all, they aren't even the same kind of thing. UUIDs are unique identifiers, you generate them to label things that couldn't be distinguished without them. Content addressing is nothing more than summarizing a given object in a way that (almost certainly) preserves identity. So, one creates distinction, the other maintains identity.