I think that this can be solved pretty simply by having each instance
generate a set of keys and insert them into the database along with a
timestamp. The database can be flushed regularly if these keys are
regenerated every X days / week / something; anything older than this can
be deleted from the table.
Simply inserting the generated key into the database assures its
uniqueness; if the insert fails due to uniqueness constraint, then
someone else has the key! So, generate a new one, insert again... etc.
Actually, that doesn't quite work, does it -- the insert for the same key
can succeed on two machines and then collide upon replication. HMM! This
is the real main problem; you *can't* generate keys without using some
kind of scheme to assure that two machines *can't* generate the same key.
I will assert, however, that MAC addresses are safe by definition. They
are frequently used for nodelocked licenses, for example, and they are
required to be unique [at the very least, within the local collision
domain] by the ARP specifications. The issues surrounding MAC addresses
are well known as well. IP addresses are probably not safe because you
certainly can get machines spoofing and faking for one another in a
failover heartbeat configuration.
I truly don't understand why the filesystem state and whatnot matters
here, because unless I'm truly missing something, what we're looking at is
the need to assume that the two messages inserted into two different
databases on two different dbmail hosts cannot ever have the same message
id. Our proposed approach is the prefix each key with some value that is
unique to the host / instance of dbmail which is doing the inserting and
therefore cannot be shared by any of the other machines in the cluster.
Aaron
On Thu, 12 Jun 2003, Jesse Norell wrote:
>
> Hello,
>
> The uuid generation needs to know the nodeid of the machine, and
> save that and some state info (timestamp and a sequence number).
> My plan was to make it read the mac addr off a hardware ethernet
> card - but if for some reason that doesn't work, or if a user
> doesn't want to give that info out in uuids, it would generate a
> random nodeid. If this is kept in a database, it would be in a
> table consisting of simply the nodeid and it's state info, and if
> that entry did not previously exist, the program would create it
> (ie. so it can save the updated state info). So.. if it's failing
> to get a mac addr from the hardware, then every message that's
> inserted ends up generating a new random nodeid and that table
> keeps growing forever.
>
> One solution would be the ability to specify a node id in
> dbmail.conf, but then you have to make sure it's different on all
> your machines, not whatever ships in the default dbmail.conf, and
> generally seems like a nuisance from a user-friendliness perspective.
> The more things that "just work" out of the box the better, imho.
>
> There's also the issue of inter-process locking of state info.
> That could be done in the database too, but would be dependant
> on the capabilities of the specific database. Filesystem files just
> seem much cleaner for this.
>
> Jesse
>
> ---- Original Message ----
> From: Magnus Sundberg <dbmail-dev@dbmail.org>
> To: dbmail-dev@dbmail.org
> Subject: Re: [Dbmail-dev] RE: unique_id discussion/problem
> Sent: Thu, 12 Jun 2003 09:41:31 +0200
>
> > Hi,
> > I have a small question, that I don't understand.
> > What reason is there to not store this data in the database?
> >
> > /Magnus
> >
> > Jesse Norell wrote:
> > > Hello,
> > >
> > > I'm working on implimenting UUID's into dbmail, and need both
> > > a place for non-volitale storage, for which I plan on using a
> > > /etc/dbmail/ directory (with a "nodeid" and "state" file), and
> > > need an inter-process locking mechanism for which I'm planning on
> > > using flock() on the state file. Does anyone see any obvious
> > > red flags going up? Is there a better/more portable/whatever
> > > way I should be locking the file?
> > >
> > > On the issue of unique_id in general, I think our whole problem
> > > was because we added constraints to guarantee that that field actually
> > > was unique - that is not necessary, and even arguably wrong. The
> > > rfc actually says that a client should be able to handle multiple
> > > messages with the same unique id if it's a duplicate message. This
> > > consideration may actually come into play if/when there are shared
> > > folders, if you can move messages from one folder to a shared folder
> > > so... just don't actually force unique_id to be unique. :)
> > >
> > > I plan on making one function to generate uuid's (for unique_id or
> > > anywhere else, if someone needs them), and then make all the pop3
> > > stuff use it everywhere it currently generates a unique_id (in
> > > multiple functions).
> > >
> > > Also, with having an /etc/dbmail/ directory, should that be the
> > > default location for dbmail.conf? Debian packages already do that,
> > > and it's cleaner if there are multiple conf/etc. files.
> > >
> > > Jesse
> > >
> > >
> > > ---- Original Message ----
> > > From: Jesse Norell <jesse@kci.net>
> > > To: jesse@kci.net
> > > Subject: unique_id discussion/problem
> > > Sent: Wed, 4 Jun 2003 10:52:58 -0600
> > >
> > >
> > >>Hello,
> > >>
> > >> We're still having issues with unique_id's not always being
> > >>unique, so - in the past there have been 2 proposed solutions,
> > >>the first to just use the message_idnr (which already exists, is
> > >>guaranteed unique and takes no additional db storage space), the
> > >>second is to use UUID's (universally unique id's). I'd be glad
> > >>to work on one or the other, but just wanted to head down the
> > >>right path.
> > >>
> > >> Is there any good reason to not use the message_idnr? It looks
> > >>like the unique_id is sent right to the pop3 client in response to
> > >>a UIDL command, so it might be handy to still have that present for
> > >>migration purposes (if someone wanted to load the unique_id's with
> > >>the same values as their previos mail server had) - what if it
> > >>uses unique_id if present, and message_idnr if NULL (or simply save
> > >>message_idnr into that field, checking for duplicates)?
> > >>
> > >> UUID's would work, but aside from seeming to be almost superfluous
> > >>overkill, there are a couple issues to work out, namely the proper
> > >>place for non-volitale storage of state info (disk file vs. database),
> > >>and testing on mulitple platforms. I've been referring to the draft at
> > >>http://lists.research.netsol.com/pipermail/urn-nid/2002-September/000323.html
> > >>as a reference. I suppose if we didn't use real mac addr's for the
> > >>node part, but a randomly generated number, there would be no platform
> > >>compatibility issues (ie. how to lookup the mac addr). The
> > >>implimentation included in the above url says it works for linux and
> > >>windows, but I can't test anything but linux myself.
> > >>
> > >>Comments / etc.?
> > >>
> > >>Jesse
> > >>
> > >>
> > >>--
> > >>Jesse Norell
> > >>jesse (at) kci.net
> > >>
> > >>
> > >
> > > -- End Original Message --
> > >
> > >
> > > --
> > > Jesse Norell
> > > jesse (at) kci.net
> > >
> > >
> > > _______________________________________________
> > > Dbmail-dev mailing list
> > > Dbmail-dev@dbmail.org
> > > http://twister.fastxs.net/mailman/listinfo/dbmail-dev
> > >
> >
> >
> >
> >
> > _______________________________________________
> > Dbmail-dev mailing list
> > Dbmail-dev@dbmail.org
> > http://twister.fastxs.net/mailman/listinfo/dbmail-dev
> >
> -- End Original Message --
>
>
> --
> Jesse Norell
> jesse (at) kci.net
>
>
> _______________________________________________
> Dbmail-dev mailing list
> Dbmail-dev@dbmail.org
> http://twister.fastxs.net/mailman/listinfo/dbmail-dev
>