Re: Remove unused variable from SharedSort

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Remove unused variable from SharedSort
Date: 2020-11-16 00:54:19
Message-ID: 20201116005419.GC2656@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Nov 15, 2020 at 03:49:58PM +0530, Dilip Kumar wrote:
> On Sun, Nov 15, 2020 at 12:50 PM Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>> We could have used that variable for an assert like
>> Assert(state->worker <= shared->nTapes) in worker_freeze_result_tape()
>> before accessing shared->tapes[state->worker] = output; as sometimes
>> state->worker is being set to -1. But, it seems like we reach
>> worker_freeze_result_tape(), only when WORKER(state) is true. So, we
>> don't need that extra Assert and removing nTapes variable makes sense
>> to me.
>
> Right, but anyway IMHO adding extra shared memory variables for just
> and assert purposes doesn't make sense.

FWIW, I disagree with the removal of this variable because it is
useful to track down the number of members in a flexible array at
shmem level. Even if you don't use that in some sanity checks for
code paths, which I think we actually should really do for at least
inittapes() and leader_takeover_tapes() when it comes to the number of
participants assumed to exist, that's useful for debugging purposes.

Robert, this code has been introduced by 9da0cc3, could you comment on
that?
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2020-11-16 01:46:35 Re: Add docs stub for recovery.conf
Previous Message Michael Paquier 2020-11-16 00:23:24 Re: Online verification of checksums