← Back to team overview

mosquitto-users team mailing list archive

Re: Bridges, persistence and retained messages (might be a bug)

 

Roger

That is impressive. Thanks for all your hard work on Mosquitto.... its a
great project and brilliant to see such fast turnaround on bugs.

Paul


On Mon, Dec 9, 2013 at 9:53 PM, Roger Light <roger@xxxxxxxxxx> wrote:

> Hi Marcus,
>
> It is a bug. Thanks for the very detailed description, it made it easy
> to figure out. I guessed what the problem was before I finished
> recreating it actually, so I'm sorry it was hard for you to find where
> things weren't working.
>
> I've pushed a fix on the 1.3 branch which should be very easy to use on
> 1.2.3:
>
>
> https://bitbucket.org/oojah/mosquitto/commits/a8e563fc0f53873500d31f217133540504735cdc
>
> Thanks!
>
> Roger
>
>
> On Mon, Dec 9, 2013 at 3:23 PM, Marcus Rejås <marcus.rejas@xxxxxxxxxx>
> wrote:
> > Problem: Messages are not being retained under some circumstances when
> > persistence is being used.
> >
> > Setup:
> >
> > Mosquitto 1.2.3
> >
> > BROKER A   <-- BRIDGE -->  BROKER B
> >
> > The bridge is initiated from Broker B.
> >
> > Config A
> >
> >   persistence true
> >   persistence_file mosquitto-A.db
> >   persistence_location /tmp/
> >   autosave_interval 3600
> >
> >   port 1883
> >
> >
> > Config B
> >
> >   persistence true
> >   persistence_file mosquitto-B.db
> >   persistence_location /tmp/
> >   autosave_interval 3600
> >
> >   port 1884
> >
> >   connection A
> >   address 127.0.0.1:1883
> >   topic # both
> >
> >
> > When starting with no persistence files it works as we expects.
> >
> > Setting a retained message on either A or B makes it retained on both
> > brokers.
> >
> > Setting on A and B
> >
> >   $ mosquitto_pub -p 1883 -t retainedA -m test -r
> >   $ mosquitto_pub -p 1884 -t retainedB -m test -r
> >
> > Verifying that the messages are retained.
> >
> >   $ mosquitto_sub -p 1883 -t \# -v
> >   retainedA test
> >   retainedB test
> >
> >   $ mosquitto_sub -p 1884 -t \# -v
> >   retainedA test
> >   retainedB test
> >
> > Works as expected.
> >
> > Removing the retained messages by sending a null-message to the topics
> > also works as expected.
> >
> > But, restarting the brokers (making them read the persistence database)
> > makes it behave different.
> >
> >   $ mosquitto_pub -p 1883 -t retainedA -m test -r
> >   $ mosquitto_pub -p 1884 -t retainedB -m test -r
> >
> >   $ mosquitto_sub -p 1883 -t \# -v
> >   retainedA test
> >   retainedB test
> >
> >   $ mosquitto_sub -p 1884 -t \# -v
> >   retainedB test
> >
> > Only the retained message set directly on B is set on B. Also remove
> > retained topics on B via the bridge does not work.
> >
> > This was little hard to find since it only occurs after restarting with
> > a persistence file present.
> >
> > Is this a bug or did we do something wrong?
> >
> > Regards
> >
> > Marcus
> >
> > --
> > Marcus Rejås
> > ALLEATO
> > Tel. +46 176 250103
> > Mobilnr: +46 70 266 79 85
> > marcus.rejas@xxxxxxxxxx
> > http://www.alleato.se
> >
> > --
> > Mailing list: https://launchpad.net/~mosquitto-users
> > Post to     : mosquitto-users@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~mosquitto-users
> > More help   : https://help.launchpad.net/ListHelp
>
> --
> Mailing list: https://launchpad.net/~mosquitto-users
> Post to     : mosquitto-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~mosquitto-users
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References