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

Tobias Oetiker oetiker at ee.ethz.ch
Wed Apr 26 07:51:15 MEST 2006


Hi Daniel,

so if the pointer magic happens the wrong way round, please note
that patches are most welcome ...

I guess since writes and reads may not be atomic in any event a
sensible locking for fetch might make sense in any way ...

your patches are welcome ...

cheers
tobi


> 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.
>
>

-- 
ETH Zurich
Tobias Oetiker, IT Support Group D-ITET (ISG.EE)
ETL F24.2, Physikstrasse 3, 8092 Zurich, Switzerland
Phone +41 44 63 25286,  http://people.ee.ethz.ch/oetiker/

--
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