X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7D56AD1B441; Mon, 5 Apr 2004 17:40:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 76432-04; Mon, 5 Apr 2004 14:41:14 -0300 (ADT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 53905D1BA90; Mon, 5 Apr 2004 14:40:43 -0300 (ADT) Received: from solent (82-68-95-1.dsl.in-addr.zen.co.uk [82.68.95.1]) by bayswater1.ymogen.net (Postfix) with ESMTP id D952B9B3FD; Mon, 5 Apr 2004 18:41:20 +0100 (BST) From: "Matt Clark" To: "Marc G. Fournier" , "Tom Lane" Cc: Subject: Re: Frequent 'deadlock detected' in 7.4 ... or just my bad Date: Mon, 5 Apr 2004 18:41:20 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal In-Reply-To: <20040405141728.C79409@ganymede.hub.org> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/70 X-Sequence-Number: 13043 > 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