pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matt Clark <matt@ymogen.net>
To: Marc G. Fournier <scrappy@postgresql.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin@postgresql.org
Subject: Re: Frequent 'deadlock detected' in 7.4 ... or just my bad
Date: Mon, 5 Apr 2004 18:41:20 +0100
Message-ID: <OAEAKHEHCMLBLIDGAFELCENEFDAA.matt@ymogen.net> (raw)
In-Reply-To: <20040405141728.C79409@ganymede.hub.org>

> 1. a traffic table is read in, and loaded into a hash table that is
>    ordered by company_id, ip_id and port:
> 
>  $traffic{$ip_rec{$ip}{'company_id'}}{$ip_id}{$port} += $bytes1 + $bytes2;
> 
> 2. a foreach loop is run on that resultant list to do the updates to the
>    database:
> 
>  foreach $company_id ( keys %traffic ) {
>    foreach $ip_id ( keys %{$traffic{$company_id}} ) {
>      foreach $port ( keys %{$traffic{$company_id}{$ip_id}} ) {
> 
>    and the updates are done based on those 3 values, plus the byte value
> of $traffic{$company_id}{$ip_id}{$port} ...
> 
>    Now, my first mistake may be that I'm mis-assuming that the hashes will
> be read in a sorted order ... ?  If this is the case, though, then sort
> order shouldn't be an issue, as all servers would be sorted the same way

The output of keys(%hash) is NOT ordered!  Try:

  foreach $company_id ( sort keys %traffic ) {
      foreach $ip_id ( sort keys %{$traffic{$company_id}} ) {
        foreach $port ( sort keys %{$traffic{$company_id}{$ip_id}} ) {


Matt




view thread (9+ messages)  latest in thread

Message-ID: <OAEAKHEHCMLBLIDGAFELCENEFDAA.matt@ymogen.net>
Permalink:  ../OAEAKHEHCMLBLIDGAFELCENEFDAA.matt@ymogen.net/
Also on:    postgresql.org/message-id/OAEAKHEHCMLBLIDGAFELCENEFDAA.matt@ymogen.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: matt@ymogen.net, scrappy@postgresql.org, tgl@sss.pgh.pa.us
  Subject: Re: Frequent 'deadlock detected' in 7.4 ... or just my bad
  In-Reply-To: <OAEAKHEHCMLBLIDGAFELCENEFDAA.matt@ymogen.net>
  References: <20040405141728.C79409@ganymede.hub.org> <OAEAKHEHCMLBLIDGAFELCENEFDAA.matt@ymogen.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox