Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYvoE-0003wu-2T for pgsql-hackers@arkaria.postgresql.org; Wed, 13 May 2020 18:08:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jYvoC-00023A-Fr for pgsql-hackers@arkaria.postgresql.org; Wed, 13 May 2020 18:08:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYvoC-000233-7F for pgsql-hackers@lists.postgresql.org; Wed, 13 May 2020 18:08:44 +0000 Received: from forwardcorp1o.mail.yandex.net ([2a02:6b8:0:1a2d::193]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYvo8-0000q8-OK for pgsql-hackers@postgresql.org; Wed, 13 May 2020 18:08:43 +0000 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 34E802E159C for ; Wed, 13 May 2020 21:08:38 +0300 (MSK) Received: from iva4-7c3d9abce76c.qloud-c.yandex.net (iva4-7c3d9abce76c.qloud-c.yandex.net [2a02:6b8:c0c:4e8e:0:640:7c3d:9abc]) by mxbackcorp2j.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id 8Q9RzOJW62-8coeM79F; Wed, 13 May 2020 21:08:38 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1589393318; bh=a2EhToS4No+a8V+2g5SYaJBa5dAeTKjMDfhkUMOKZdU=; h=Message-Id:In-Reply-To:To:References:Date:Subject:From; b=p/QCJqvHG4KzyuNv8HaNGcYHHpTa7SsPRwP36g3wXFrlSP6sbj2Q3bUQiYzTKOjVL OEhX7ZFJfstFLceMRS77qutt5iKAi0fPTvO0Mk3GuprfT0a/WtE/QtZ4vK5YUVVpke oUF7ra15+Byaanks+VzN7FWXDBYxRZwTk3ERrm84= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-iva.dhcp.yndx.net (dynamic-iva.dhcp.yndx.net [2a02:6b8:b080:8818::1:0]) by iva4-7c3d9abce76c.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id yNxywX5JnC-8bWiUkDb; Wed, 13 May 2020 21:08:38 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) From: "Andrey M. Borodin" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Subject: Re: MultiXact\SLRU buffers configuration Date: Wed, 13 May 2020 23:08:37 +0500 References: <2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86@yandex-team.ru> <801D899E-9CC5-4FEE-AAA4-16D87853FD45@yandex-team.ru> To: PostgreSQL-development In-Reply-To: <801D899E-9CC5-4FEE-AAA4-16D87853FD45@yandex-team.ru> Message-Id: X-Mailer: Apple Mail (2.3608.60.0.2.5) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > 11 =D0=BC=D0=B0=D1=8F 2020 =D0=B3., =D0=B2 16:17, Andrey M. Borodin = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0):= >=20 > I've went ahead and created 3 patches: > 1. Configurable SLRU buffer sizes for MultiXacOffsets and = MultiXactMembers > 2. Reduce locking level to shared on read of MultiXactId members > 3. Configurable cache size I'm looking more at MultiXact and it seems to me that we have a race = condition there. When we create a new MultiXact we do: 1. Generate new MultiXactId under MultiXactGenLock 2. Record new mxid with members and offset to WAL 3. Write offset to SLRU under MultiXactOffsetControlLock 4. Write members to SLRU under MultiXactMemberControlLock When we read MultiXact we do: 1. Retrieve offset by mxid from SLRU under MultiXactOffsetControlLock 2. If offset is 0 - it's not filled in at step 4 of previous algorithm, = we sleep and goto 1 3. Retrieve members from SLRU under MultiXactMemberControlLock 4. ..... what we do if there are just zeroes because step 4 is not = executed yet? Nothing, return empty members list. What am I missing? Best regards, Andrey Borodin.=