I currently use the following in our sql logging plugin to generate a unique id in the database:
my @sname = split(/\./, $self->qp->config("me")); my $sqlIdent = $sname[0].$$.'r'.int( (( time ^ $$ ) * rand($$)) / rand(time/$$)); With each mx box running at ~30 cps we get dups often enough I'm considering changing it. On 8/23/07 1:34 PM, "David Sparks" <[EMAIL PROTECTED]> wrote: > JT Moree wrote: >> Hanno Hecker wrote: >>>> Is there a message ID that is unique to each message? >>> Not until the sending client has submitted a 'Message-ID' header ;-) >> >>> But it would be easy to add / generate a transaction id after every >>> reset_transaction() call. This could be logged instead of (or as >>> addition to) the PID. >> >>> + $self->{_transaction_id} = sprintf("%08X", rand(2**32 - 1)); > > I calculate transaction ids like this (hires time): > > my $mid = sprintf("%.4f%d", time(), $self->{_id}); > > $self->{_id} is the id of the server and currently calculated by using > the last digit of the IP address. This allows transaction ids to be > unique across 10 servers. When servers get fast enough this may end up > causing dup ids. A scheme like this allows easy auditing of problems > because the id contains the "when and where". > > Cheers, > > ds > > > >> >> Is this uique enough? what is the chance of getting the same random >> number again? should it be a combination of the PID + time + rand? > -- Ed McLain Sr. Data Center Engineer TekLinks, Inc. 205.314.6634 [EMAIL PROTECTED]