On Sun, Nov 22, 2009 at 5:42 AM, Howard Chu hyc@symas.com wrote:> but it will only write related data if (update_ctxcsn)
The manpage clearly states that -S sets the SID used in generated entryCSNs.
It also clearly states that the -w option writes the contextCSN based on the greatest entryCSN in the database.
Period, end of story.
Indeed.
So the consequence is that the -S <sid> option is used to initialize the entryCSN's, regardless of if the -w option being provided.
If the -w option is provided, then the entryCSN's are searched for the maximal entryCSN, which becomes the contextCSN (either recently generated, or provided as part of the LDIF being loaded)
If the -S is not provided, it defaults to 0.
Just to clarify (your first statement sounds a bit ambiguous to me): -w and -S are sort of orthogonal.
If the database has "lastmod on", slapadd adds entryCSN (and entryUUID, and createTimestamp, modifyTimestamp and so) unless already present in the LDIF. Already present values are left untouched.
The entryCSN is generated using the SID passed with -S; it defaults to 0.
When -w is used, the largest entryCSN for each independent SID is collected, regardless of being generated or already present in the LDIF, and written in the contextCSN (as soon as slapadd's execution is successful, of course). The contextCSN is multi-valued.
So, for example, an LDIF like this (skipping unnecessary details)
dn: dc=example,dc=com entryCSN: 20091122093849.380000Z#000000#000#000000
dn: ou=People,dc=example,dc=com entryCSN: 20091122093850.380000Z#000000#001#000000
dn: ou=Groups,dc=example,dc=com entryCSN: 20091122093851.380000Z#000000#002#000000
dn: cn=Someone,ou=People,dc=example,dc=com # no entryCSN
run with slapadd -w -S 3 will result in
dn: dc=example,dc=com entryCSN: 20091122093849.380000Z#000000#000#000000 # gathered by slapadd run with -w contextCSN: 20091122093849.380000Z#000000#000#000000 contextCSN: 20091122093850.380000Z#000000#001#000000 contextCSN: 20091122093851.380000Z#000000#002#000000 contextCSN: 20091122093852.380000Z#000000#003#000000
dn: ou=People,dc=example,dc=com entryCSN: 20091122093850.380000Z#000000#001#000000
dn: ou=Groups,dc=example,dc=com entryCSN: 20091122093851.380000Z#000000#002#000000
dn: cn=Someone,ou=People,dc=example,dc=com # added by slapadd, with SID=3 as passed by -S 3 entryCSN: 20091122093852.380000Z#000000#003#000000
Hope this clarifies. Feel free to turn this into a FAQ entry, or better an example for the Admin Guide :)
p.