Issue 1323 - MAJOR slurpd: ri.c: Using strcmp() on the Timestamp
Summary: MAJOR slurpd: ri.c: Using strcmp() on the Timestamp
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-09-09 16:15 UTC by jtavares@loa.com
Modified: 2014-08-01 21:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kurt Zeilenga 2001-09-09 12:38:53 UTC
moved from Incoming to Software Bugs
Comment 1 Kurt Zeilenga 2001-09-09 14:42:22 UTC
changed notes
changed state Open to Test
Comment 2 jtavares@loa.com 2001-09-09 16:15:28 UTC
Full_Name: James Tavares
Version: 1.2.12
OS: Solaris 7
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (24.218.235.205)


This weekend we witnessed the historic change from 999,999,999 seconds to
1,000,000,000 in the unix seconds-since-epoch counter.

At the same time, all replication on my systems ceased to exist. Running slurpd
in debug mode claimed that the records in my slurpd.replog were OLDER than what
my slurpd.status showed, which was easily verified as FALSE... My slurpd.status
hadn't been updated since 999,999,942 (verified to be TRUE against the file
dates on the slave servers) and records in my slurpd.replog were dated
1,000,000,000 and beyond.

I grep'd for the "skip repl record for" error message and found it in
slurpd/ri.c. As you all know, the function "ri.c:isnew()" is responsible for
determining if a REPLOG entry is newer than the last update recorded in
SLURPD.STATUS. However, the function uses strcmp() to compare the two
timestamps. Since strcmp() compares alphabetically, it makes sense that slurpd
was reporting 1,000,000,000 to be older than 999,999,942. A simple (and working)
patch follows:

24a25
> #include <math.h>
229d229
<     int       x;
234,235c234
<     x = strcmp( re->re_timestamp, ri->ri_stel->last );
<     if ( x > 0 ) {
---
>     if ( atof(re->re_timestamp) > atof(ri->ri_stel->last) ) {
238c237
<     } else if ( x < 0 ) {
---
>     } else if ( atof(re->re_timestamp) < atof(ri->ri_stel->last) ) {


I am not very familiar with openldap source code (this is the first time I've
looked through it) so to be sure I didn't miss anything I used atof() instead of
atoi().. I remember seeing a ".0" on a timestamp once in slurpd.replog, and
while I guess that could be the sequence number referenced later in the function
as opposed to some fractional-second, I didn't want to take any chances. Feel
free to correct it to atoi() if re->re_timestamp and ri->ri_stel->last are
guaranteed to be integers (whole seconds from time()).

Also, I have no idea where ELSE in slapd / slurpd source code this type of bug
may exist. I just happened to locate this one while trying to get my replication
working :) Which, by the way, this patch (at least) seems to have fixed.

Any questions? Just bounce me an email: jtavares@loa.com.

Comment 3 Kurt Zeilenga 2001-09-09 16:29:07 UTC
changed notes
changed state Test to Release
Comment 4 Kurt Zeilenga 2001-09-09 16:59:11 UTC
changed notes
Comment 5 Kurt Zeilenga 2001-09-09 23:46:30 UTC
I committed changes to OPENLDAP_REL_ENG_2 which should
resolve this issue.  http://www.openldap.org/software/repo.html
Please test, thanks.

Comment 6 Kurt Zeilenga 2001-09-10 09:51:12 UTC
changed notes
changed state Release to Closed
Comment 7 Norbert Klasen 2001-09-11 13:58:45 UTC
From the release notes:
> OpenLDAP 2.0.14 Release
> 	Fixed slurpd millionth second bug (ITS#1323)

Shouldn't that be the billionth second?

-- 
Norbert Klasen
DAASI International GmbH                 phone: +49 7071 29 70336
Wilhelmstr. 106                          fax:   +49 7071 29 5114
72074 Tübingen                           email: norbert.klasen@daasi.de
Germany                                  web:   http://www.daasi.de


Comment 8 Howard Chu 2003-12-12 22:57:48 UTC
moved from Software Bugs to Archive.Software Bugs
Comment 9 OpenLDAP project 2014-08-01 21:06:20 UTC
fixed in HEAD
fixed in re20