eclipse-iceoryx / iceoryx

Eclipse iceoryx™ - true zero-copy inter-process-communication
https://iceoryx.io
Apache License 2.0
1.68k stars 393 forks source link

Problems with multiple "persistent" publishers on the same topic at subscriber startup #2207

Closed FabioBagni closed 8 months ago

FabioBagni commented 8 months ago

Hi, we're having trouble trying to implement "persistent" publishers and subscribers.

To do that we are initializing publishers with publisherOptions.historyCapacity = 10 (or any size > 0), and subscribers with subscriberOptions.historyRequest = 1.

With these options, the subscriber receives the latest published message at its creation.

The problem is that if we have multiple publishers with these options publishing on the same topic, the subscriber receives the latest published message from each publisher.

So, is there a way to understand which one of the received messages is the latest?

elBoberido commented 8 months ago

Unfortunately not. With multiple publisher it is quite difficult to determine a right order because everybody might define it in a different way.

You could circumvent the issue somehow by using a UserHeader with a timestamp and have a local cache which orders the samples according to your needs.

The problem with multiple publishers and history is that there are inherent races. Let's assume you have three publisher, A, B and C:

-> although A has the oldest data, it has the newest timestamp

elBoberido commented 8 months ago

@FabioBagni Are your questions answered and can this be closed?

FabioBagni commented 8 months ago

Yes the answers are very clear, thanks.

I solved it writing timestamp inside the payload and manually discarding everything but the latest.