Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKltc-0003eD-WA for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Nov 2018 15:07:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gKlta-0001LA-5Q for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Nov 2018 15:06:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKltZ-0001Kz-Om for pgsql-hackers@lists.postgresql.org; Thu, 08 Nov 2018 15:06:57 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gKltW-00089S-Pl for pgsql-hackers@postgresql.org; Thu, 08 Nov 2018 15:06:57 +0000 Received: by mail-wr1-x442.google.com with SMTP id v18-v6so2307095wrt.8 for ; Thu, 08 Nov 2018 07:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/AFkjH8Q7J8SjBQml6axt4dI7K7GUFbYdNCw8VqbXY4=; b=XHbBayEea/K5vvD2gvLab/KjqB4IXrIUkX/idjQ+5LHljVMoZqoaiSZysjllzHPKFf 2LnF2SEOfnYq11G0AamhmXgKpPs9OwbZRg1U4UMGXz+ltALytFWPq2FOVuEj+eQc0j2T 0POAYIjuebPLPh3vJ6Y/ZM9VGh6+qdfPYkge21cLffh9nKeF0w/q0tPx5NAYlD0z11So c1W68QX5qKF2QQcS2V1Oxp93OecPE5Y++NOIJHAvnT4wR1jDFR8g12nEPXMfz82Jii7r PYUzDRT4He9NVMx6YMAyyBu1zO68IrJnI6oiDXGmFGHcAukIzDYjH7DXld+0t+47yLjw WFEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/AFkjH8Q7J8SjBQml6axt4dI7K7GUFbYdNCw8VqbXY4=; b=bEOfRPgFHbreD5kp3IoztyK5EW+4flk9Ie8jnZwTlWkf/LB0iHgleQjZWCEmpWMEqK 1W6Lki4IyYOFySVTPHx3gcS3s2iIxE8RYtbB5nqm7EEkNliV+lYSyiYsVXSInRt43WTF PNZhgbgwI0ItdnJqXcT85jBJgsmSpUago2nMZollX0qjn8IoAhqPineNtZpN9QXCYIyY KCYoi8JOV0RQuHY4gbCn3snUh4f9VhRXJ79doU4ggXtLM9PIsEehezdFFGloOBgpWodf 3g8bS7hHiJDjBkjmvPXppg13z4Xu7Vq41JhhUOuSLk1xMCrwtL3Iu9IwFl1OuGwBr+vO BKRw== X-Gm-Message-State: AGRZ1gKLoiH4X/cZJeQ/G4R1jFOvkHCoNYTk3+FbuQftWJDi22JhyZ3t CkOQ9JRc/P2QPZU/lPujxpgdaNSclYsIdqmKAzRg7nd6t7rODTJMiCjbzulvNO7k16AYko/LZNB NM0B2WohRB+QTMeTMZsfRHzHwQh6EWI6Uju6K8CXpleGg+YHlbSEZZCKUuAj2MH+e/upGj0C4OY SUxijTlAU3SgAt2g== X-Google-Smtp-Source: AJdET5ei8ehzUgd/XKtEvjE6ptpHGu/pGfMACNriBZO+1MH/kY3HJWUVXU/jC1ktUUNGiGsNvT+8Zw== X-Received: by 2002:adf:f148:: with SMTP id y8-v6mr4622390wro.303.1541689613057; Thu, 08 Nov 2018 07:06:53 -0800 (PST) Received: from [10.137.2.21] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id 67-v6sm4527166wmd.1.2018.11.08.07.06.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 07:06:52 -0800 (PST) Subject: Re: shared-memory based stats collector To: Kyotaro HORIGUCHI Cc: andres@anarazel.de, ah@cybertec.at, magnus@hagander.net, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org References: <20181002.160651.117284090.horiguchi.kyotaro@lab.ntt.co.jp> <20181005.173017.151015949.horiguchi.kyotaro@lab.ntt.co.jp> <5253d750-890b-069b-031f-2a9b73e47832@2ndquadrant.com> <20181108.204648.45949674.horiguchi.kyotaro@lab.ntt.co.jp> From: Tomas Vondra Message-ID: Date: Thu, 8 Nov 2018 16:06:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181108.204648.45949674.horiguchi.kyotaro@lab.ntt.co.jp> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/8/18 12:46 PM, Kyotaro HORIGUCHI wrote: > Hello. Thank you for looking this. > > At Tue, 30 Oct 2018 01:49:59 +0100, Tomas Vondra wrote in <5253d750-890b-069b-031f-2a9b73e47832@2ndquadrant.com> >> Hi, >> >> I've started looking at the patch over the past few days. I don't have >> any deep insights at this point, but there seems to be some sort of >> issue in pgstat_update_stat. When building using gcc, I do get this >> warning: >> >> pgstat.c: In function ‘pgstat_update_stat’: >> pgstat.c:648:18: warning: ‘now’ may be used uninitialized in this >> function [-Wmaybe-uninitialized] >> oldest_pending = now; >> ~~~~~~~~~~~~~~~^~~~~ >> PostgreSQL installation complete. > > Uggh! The reason for the code is "last_report = now" comes later > than the code around... Fixed. > >> When running this under valgrind, I get a couple of warnings in this >> area of code - see the attached log with a small sample. Judging by >> the locations I assume those are related to the same issue, but I have >> not looked into that. > > There was several typos/thinkos related to pointers modifed from > original variables. There was a code like the following in the > original code. > > memset(&shared_globalStats, 0, siazeof(shared_globalStats)); > > It was not fixed despite this patch changes the type of the > variable from PgStat_GlboalStats to (PgStat_GlobalStats *). As > the result major part of the varialbe remaineduninitialized. > > I re-ran this version on valgrind and I didn't see such kind of > problem. Thank you for the testing. > OK, regression tests now seem to pass without any valgrind issues. However a quite a few extensions in contrib seem are broken now. It seems fixing it is as simple as including the new bestatus.h next to pgstat.h. I'm not sure splitting the headers like this is needed, actually. It's true we're replacing pgstat.c with something else, but it's still related to stats, backing pg_stat_* system views etc. So I'd keep as much of the definitions in pgstat.h, so that it's enough to include that one header file. That would "unbreak" the extensions. Renaming pgstat_report_* functions to bestatus_report_* seems unnecessary to me too. The original names seem quite fine to me. BTW the updated patches no longer apply cleanly. Apparently it got broken since Tuesday, most likely by the pread/pwrite patch. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services