If you try to run the dbscan tool against a changelog db on a stopped server, it reports the an error similar to: dbid: 0000006f000000000000 Invalid changelog db version 1 Works for version 5 only. The print_changelog function in dbscan.c expects all entries to have 0x05 as the first byte, which signifies the changelog version. This version check should be done for all change entries in the changelog db, but there are three special entries that are in the beginning of the changelog where this doesn't apply. These entries are an entry count, the purge RUV, and the max RUV. It should be noted that these entries are not always present when the server is running, so dbscan will often work fine against a running server. When the server is stopped gracefully, these entries are flushed out to be used once the server is restarted. The attached diffs make dbscan check for these special entries when reading through a changelog. If it encounters one of these entries, it will print out the data in a nice usable format. Here is an example of the output for these three entries with my changes: dbid: 0000006f000000000000 entry count: 5 dbid: 000000de000000000000 purge ruv: {replicageneration} 46f806a2000000030000 {replica 3 ldap://snail.example.com:389} {replica 1 ldap://snail.example.com:389} dbid: 0000014d000000000000 max ruv: {replicageneration} 46f806a2000000030000 {replica 3} 46f808dc000100030000 46f808dc000100030000 {replica 1} 46f812b2000000010000 46f813cf000000010000
Created attachment 204611 [details] CVS Diffs
Looks good. You should probably put a comment near the definition of ENTRY_COUNT_KEY etc. explaining where these values come from in cl5_api.c. Also, it looks as though there is a bug in cl5ReadBervals(). In your code, you use ntohl to read the number of bervals. But in the cl5 code, it uses PR_htonl to read this value. This is not correct because it uses PR_htonl to encode the values.
This is also in cl5_api.c. :) If you have a chance to fix the bug that Rich pointed out above, could you add (time_t) before passing type to csn_set_time? static char* _cl5GetHelperEntryKey (int type, char *csnStr) { CSN *csn= csn_new(); char *rt; csn_set_time(csn, type); <=== type: cast to time_t. void csn_set_time(CSN *csn, time_t csntime) { csn->tstamp= csntime; } struct csn { time_t tstamp;
Created attachment 204671 [details] Revised Diffs These revised diffs address the two issues that Rich and Noriko raised.
Checked into ldapserver (HEAD). Thanks to Rich and Noriko for their reviews! /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_api.c,v <-- cl5_api.c new revision: 1.16; previous revision: 1.15 done Checking in slapd/tools/dbscan.c; /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/dbscan.c,v <-- dbscan.c new revision: 1.17; previous revision: 1.16 done