Re: [HACKERS] tablesync patch broke the assumption that logical repdepends on? - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [HACKERS] tablesync patch broke the assumption that logical repdepends on?
Date
Msg-id ab634fc3-d9f4-79f0-6ea0-34cc16a4e6b0@2ndquadrant.com
Whole thread Raw
In response to Re: [HACKERS] tablesync patch broke the assumption that logical repdepends on?  (Petr Jelinek <petr.jelinek@2ndquadrant.com>)
Responses Re: [HACKERS] tablesync patch broke the assumption that logical repdepends on?
List pgsql-hackers
On 4/21/17 10:11, Petr Jelinek wrote:
> On 21/04/17 16:09, Peter Eisentraut wrote:
>> On 4/20/17 14:29, Petr Jelinek wrote:
>>> +        /* Find unused worker slot. */
>>> +        if (!w->in_use)
>>>          {
>>> -            worker = &LogicalRepCtx->workers[slot];
>>> -            break;
>>> +            worker = w;
>>> +            slot = i;
>>> +        }
>>
>> Doesn't this still need a break?  Otherwise it always picks the last slot.
>>
> 
> Yes it will pick the last slot, does that matter though, is the first
> one better somehow?
> 
> We can't break because we also need to continue the counter (I think the
> issue that the counter solves is probably just theoretical, but still).

I see.  I think the code would be less confusing if we break the loop
like before and call logicalrep_sync_worker_count() separately.

> Hmm actually, maybe the if (!w->in_use) should be if (worker == NULL &&
> !w->in_use)?

That would also do it.  But it's getting a bit fiddly.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] Interval for launching the table sync worker
Next
From: Ashutosh Bapat
Date:
Subject: Re: [HACKERS] Partition-wise join for join between (declaratively)partitioned tables