[LDB] Store index DNs as canonical case

simo idra at samba.org
Wed Sep 9 06:59:47 MDT 2009


On Wed, 2009-09-09 at 12:53 +1000, Andrew Bartlett wrote:
> On Tue, 2009-09-01 at 08:31 -0400, simo wrote:
> > On Tue, 2009-09-01 at 21:59 +1000, Andrew Bartlett wrote:
> > > --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
> > > +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
> > > @@ -29,6 +29,8 @@ struct ltdb_private {
> > >         bool check_base;
> > >         struct ltdb_idxptr *idxptr;
> > >         bool prepared_commit;
> > > +
> > > +       int casefold_index;
> > >  };
> > 
> > Why casefold_index ?
> > I'd rather call it index version, and have an index_v00_to_v01 upgrade
> > function. If later on we need to change something else we will be able
> > to bump up index_version to 02 and chain a index_v01_to_v02 upgrade
> > function.
> 
> I've reworked the code again, and I wonder if you might like to look it
> over.  We now use a index version, as requested.
> 
> The only issue I can see is that if someone was to upgrade to index
> version 1, then edit using older LDB tools, that will work fine.  But if
> they then use the new tools again (which detect the new index version in
> the header) they won't have correct indexes (as the old tools wont
> casefold or sort). 
> 
> Is this failure mode (which only shows up on upgrade/downgrade/upgrade)
> acceptable?
> 
> One 'way out' is to never up the index version on old databases, and pay
> a runtime penalty (until a manual change is made).  But new databases
> would still work with the old code, and so the same problem could arise.

There is another way that would make the database compatible albeit slow
for *old* tools. Change all indexing attribute names including the list
of indexes we keep, when we change to the new index version.

In a new code keep a copy of the highest sequence number in the new
index list attribute. If someone uses the old tools, they will be slow
(no indexes) but, more importantly, they will not update the sequence
number copy when they perform any operation that modifies the database.

On start-up, the new code should compare the 2 sequence numbers, and if
they mismatch, force a re-index.

I see 2 problems:
- we need to make sure all code updates always both sequence numbers.
- we are out of luck if someone uses old tools against a database that
is in use by the new code at the same time, but that's always going to
be the case.

So given point 2 I am not sure we really want to go this way.
We may simply decide to live with the fact that using old tools to
modify the database is going to be a problem.

> (Sadly existing LDB versions don't seem to have a way to reject
> databases based on index versions.  I could add this from this point
> forward however). 

I think we should start adding a version number now, so that we won't
have this problem in future versions.

> See git://git.samba.org/abartlet/samba.git ldb-index-rewrite

I will try to take a deeper look later on, but on a cursory look I don't
see anything that strikes me as evidently odd.

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Principal Software Engineer at Red Hat, Inc. <simo at redhat.com>



More information about the samba-technical mailing list