[rrd-users] Re: Atomicity of updates from a reader's POV ?

Alex van den Bogaerdt alex at ergens.op.het.net
Wed Apr 26 04:31:19 MEST 2006

On Wed, Apr 26, 2006 at 02:36:04AM +0100, Daniel P. Berrange wrote:

> My question is: are the updates applied  atomically as far as the readers
> are concerned? I notice that the code in the update method takes out a write
> fcntl() lock on the database, and then performs a whole sequence of fwrite() 
> calls. The fetch methods do not take out a corresponding read lock with
> fcntl(). Thus if a reader were to extract data while the writer is in the
> middle of its sequence of fwrite() calls, could the reader get either 
> corrupt, or incomplete data for the most recent sample ?  I'm hoping the
> data file format is structured such that the reader will never see a partial
> updated sample, but I can't tell for sure by looking at the code. 

You have looked in the code, so you know roughly where to look and I can
be lazy:

Does the pointer to the recent data get advanced before or after the writes?

Would it be advanced after writing data, I guess the oldest value may be
overwritten with new data, but be visible to the user as old data.

If OTOH the pointer is advanced first, the user is presented old data as
if it were new.

So, changing 'last update' or whatever it is called exactly is important
here.  If I had to guess, I would put my money on the first described case,
where the pointer is moved after doing all of the updates.

By the way: many updates won't be seen by the user.  The user is looking at
one RRA at a time, each update may change multiple RRAs.  And at least one
of the writes is the one changing the house keeping sections, where 'last
update' is changed.

Alex van den Bogaerdt

Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi

More information about the rrd-users mailing list