Re: MultiXact\SLRU buffers configuration
x4mmm@yandex-team.ru
From: "Andrey M. Borodin" <x4mmm@yandex-team.ru>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-05-15T09:01:46Z
Lists: pgsql-hackers
> 15 мая 2020 г., в 05:03, Kyotaro Horiguchi <horikyota.ntt@gmail.com> написал(а): > > At Thu, 14 May 2020 11:44:01 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in >>> GetMultiXactIdMembers believes that 4 is successfully done if 2 >>> returned valid offset, but actually that is not obvious. >>> >>> If we add a single giant lock just to isolate ,say, >>> GetMultiXactIdMember and RecordNewMultiXact, it reduces concurrency >>> unnecessarily. Perhaps we need finer-grained locking-key for standby >>> that works similary to buffer lock on primary, that doesn't cause >>> confilicts between irrelevant mxids. >>> >> We can just replay members before offsets. If offset is already there - members are there too. >> But I'd be happy if we could mitigate those 1000us too - with a hint about last maixd state in a shared MX state, for example. > > Generally in such cases, condition variables would work. In the > attached PoC, the reader side gets no penalty in the "likely" code > path. The writer side always calls ConditionVariableBroadcast but the > waiter list is empty in almost all cases. But I couldn't cause the > situation where the sleep 1000u is reached. Thanks! That really looks like a good solution without magic timeouts. Beautiful! I think I can create temporary extension which calls MultiXact API and tests edge-cases like this 1000us wait. This extension will also be also useful for me to assess impact of bigger buffers, reduced read locking (as in my 2nd patch) and other tweaks. >> Actually, if we read empty mxid array instead of something that is replayed just yet - it's not a problem of inconsistency, because transaction in this mxid could not commit before we started. ISTM. >> So instead of fix, we, probably, can just add a comment. If this reasoning is correct. > > The step 4 of the reader side reads the members of the target mxid. It > is already written if the offset of the *next* mxid is filled-in. Most often - yes, but members are not guaranteed to be filled in order. Those who win MXMemberControlLock will write first. But nobody can read members of MXID before it is returned. And its members will be written before returning MXID. Best regards, Andrey Borodin.
Commits
-
Rework new SLRU test with injection points
- 94a3373ac5c3 18.0 landed
-
injection_point: Add injection_points.stats
- 2e35c67f9568 18.0 landed
-
injection_points: Add initialization of shmem state when loading module
- b2b023aa3706 18.0 landed
-
Add injection-point test for new multixact CV usage
- 768a9fd5535f 18.0 landed
-
Use conditional variable to wait for next MultiXact offset
- a0e0fb1ba56f 17.0 landed
-
Improve performance of subsystems on top of SLRU
- 53c2a97a9266 17.0 landed
-
Adjust VACUUM hastup LP_REDIRECT comments.
- 325bc54eed4e 16.0 cited
-
Test replay of regression tests, attempt II.
- f47ed79cc8a0 15.0 cited