Using D-BUS to notify apps of a pending snapshot?
Craig Ringer
craig at postnewspapers.com.au
Wed Aug 4 01:48:21 PDT 2004
Hi folks
I've been toying with the idea of using D-BUS
(http://freedesktop.org/Software/dbus ) to notify applications enhanced
to be D-BUS aware of a pending snapshot, and thought I'd ask here for
feedback. It's doubtful that I would be able to implement this myself -
at least in a reasonable time-frame - but perhaps the idea might be
useful to somebody.
Currently a snapshot will be of a synced filesystem that should be
fairly consistent. However, I haven't seen a way to notify running
daemons that their storage is about to be snapshotted, so they should
make it consistent then hold changes. For example when taking a snapshot
of /var with PostgreSQL, Cyrus IMAPd and postfix running it appears to
be possible to end up with a snapshot with things like a new message in
a mail directory but no index entry for it. The only way to assure a
snapshot that's consistent at the application level seems to be to stop
the daemons, and this makes it difficult to take a snapshot without
interrupting services on a machine.
Even if some apps provide existing 'freeze' features, their use requires
administrator action or extra scripting that's specific to each
application. Such apps would seem ideally positioned to benefit from
D-BUS snapshot notification, as the freeze functionality is already in
place and they just need to add another way of triggering it. Other apps
would also need to add a freeze function, which is a bit more work.
So ... I'm wondering if D-BUS might be a good choice for a communication
mechanism between the LVM tools and aware applications. Ideally aware
applications would flush file descriptors and hold pending transactions
until they were notified that the snapshot had been taken. Apps that
were not aware of D-BUS or not set up to listen for the snapshot
notifications wouldn't be affected at all.
The way I was thinking things might be done is for LVM to send a D-BUS
message warning that a snapshot had been requested. Aware applications
would respond ASAP with a message informing LVM they're aware of the
request. Each app would send another message once it'd synced and
flushed everything and it's on-disk storage was ready for the snapshot.
Once all aware apps send the ready message, the LVM tools would actually
take the snapshot, then notify the apps it had been completed.
Questions that remain:
- A good way of determining aware apps. The approach above suffers from
timing issues, as LVM must decide to wait only x seconds before assuming
no other apps will make themselves known. D-BUS provides a way to
discover other listening processes, so perhaps this would be a better
approach.
- How to handle the situation of an aware app not responding? Time out
and take the snapshot anyway?
It should be easy to make D-BUS support a compile-time option for the
LVM tools, so I don't expect there to be problems with introducing new
dependencies.
So ... thoughts/opinions anybody? Am I thinking about this all
backwards? Do the admins on this list like the idea of 'lvcreate -s'
automatically making sure apps put their on-disk storage in a consistent
state before a snapshot, or is there no real demand for this?
Personally, I'm most interested in this to make sure snapshots of /var
have my mail system in a 'stable' state - no half-delivered messages,
messages delivered to Cyrus but not removed from the postfix queue yet,
etc. I'm sure plenty of other uses would pop up.
I've CC'd this to the D-BUS folks in case they have any comments or
concerns.
--
Craig Ringer
More information about the dbus
mailing list