Re: Frequent 'deadlock detected' in 7.4 ... or just my bad - Mailing list pgsql-admin

From Matt Clark
Subject Re: Frequent 'deadlock detected' in 7.4 ... or just my bad
Date
Msg-id OAEAKHEHCMLBLIDGAFELCENEFDAA.matt@ymogen.net
Whole thread Raw
In response to Re: Frequent 'deadlock detected' in 7.4 ... or just my bad  ("Marc G. Fournier" <scrappy@postgresql.org>)
Responses Re: Frequent 'deadlock detected' in 7.4 ... or just my bad
List pgsql-admin
> 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


pgsql-admin by date:

Previous
From: Suresh
Date:
Subject: Installation Docs for Linux and Windows
Next
From: Andrew Sullivan
Date:
Subject: Re: Do Petabyte storage solutions exist?