答复: [BUGS] 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border

From: shao bret <bret(dot)shao(at)outlook(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: 答复: [BUGS] 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border
Date: 2017-04-12 02:17:11
Message-ID: HK2PR0201MB0882F868D8EF2A49179C127BE6030@HK2PR0201MB0882.apcprd02.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Andres,

Yes, your solution is same with my. I have attached the patch file in former email.
Sorry for my mistake for this code. This code is come from 9.5.3. after that ,I create a patch file using 9.6.2.
The attachment is the email.
>if (!found)
> {
> int i;
> MemSet(replication_states_ctl, 0, ReplicationOriginShmemSize());
> replication_states_ctl->tranche_id = LWLockNewTrancheId();
> replication_states_ctl->tranche.name = "ReplicationOrigins";
> replication_states_ctl->tranche.array_base =
> &replication_states[0].lock;
> replication_states_ctl->tranche.array_stride =
> sizeof(ReplicationState);
>
> //MemSet(replication_states, 0, ReplicationOriginShmemSize());
>
> for (i = 0; i < max_replication_slots; i++)
> LWLockInitialize(&replication_states[i].lock,
> replication_states_ctl->tranche_id);
> }

Thanks
Bret

发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用

发件人: Andres Freund<mailto:andres(at)anarazel(dot)de>
发送时间: 2017年4月11日 23:22
收件人: shao bret<mailto:bret(dot)shao(at)outlook(dot)com>
抄送: Michael Paquier<mailto:michael(dot)paquier(at)gmail(dot)com>; PostgreSQL mailing lists<mailto:pgsql-bugs(at)postgresql(dot)org>
主题: Re: [BUGS] 答复: [BUGS] BUG #14615: ReplicationOriginShmemInit Memory access cross-border

On 2017-04-10 07:02:06 +0000, shao bret wrote:
> Hi Michael,
> Thanks for your quickly response!
> I think maybe you have a little misunderstanding with my solution.
>
> My solution is that
> if (!found)
> {
> int i;
> MemSet(replication_states_ctl, 0, ReplicationOriginShmemSize());
> replication_states_ctl->tranche_id = LWLockNewTrancheId();
> replication_states_ctl->tranche.name = "ReplicationOrigins";
> replication_states_ctl->tranche.array_base =
> &replication_states[0].lock;
> replication_states_ctl->tranche.array_stride =
> sizeof(ReplicationState);
>
> //MemSet(replication_states, 0, ReplicationOriginShmemSize());
>
> for (i = 0; i < max_replication_slots; i++)
> LWLockInitialize(&replication_states[i].lock,
> replication_states_ctl->tranche_id);
> }
> So I think it’s easier for understanding code.
> What do you think?

That's imo just more work to maintain if additional fields added.

- Andres

Attachment Content-Type Size
答复_ 答复_ [BUGS] BUG #14615_ ReplicationOriginShmemInit Memory access cross-border.eml application/octet-stream 7.0 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Noah Misch 2017-04-12 02:56:00 Re: postmaster became multithreaded
Previous Message Michael Paquier 2017-04-11 23:49:16 Re: BUG #14615: ReplicationOriginShmemInit Memory access cross-border