Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhcgc-00CWPr-8h for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Mar 2024 21:50:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rhcga-002xc5-IY for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Mar 2024 21:50:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhcga-002xWM-97 for pgsql-hackers@lists.postgresql.org; Tue, 05 Mar 2024 21:50:56 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rhcgQ-00325J-Rt for pgsql-hackers@lists.postgresql.org; Tue, 05 Mar 2024 21:50:53 +0000 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-7c810b04bc0so256978839f.2 for ; Tue, 05 Mar 2024 13:50:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709675447; x=1710280247; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mNaPcD8C1CaGfR8dSQp5MOtj1v2kWxS0AYvgOxX1T3o=; b=dsvUC9V8f85TDfB3UuoV2ZW2otlhj7MMoxZ/sWUuS09f9TuSeArmto5u49wasvIWzp Z6AuLWZ76mNBH3trmPz8ZaGsO/khinn6QitkMJI0OcA/1e3NAWU9seNISRoQinEnSRdu BzWGzL+9BnG+NAqF70ymU7TdcgrPn8LMy/nfxfGr2geKYkkWq+0PbGnWdXfCLNoOw4+0 +CpttS6SyhxtwoV44AOKcLfmlLnc6XNFtoDbDGtjDn4GplTqM7mWbEsAWqrfHHq69mGn PwHntmWZGQHFzm/BiedkMqHjiaBKWbxmCtl6VUK9XVHbqat5YG5X/Be6s57meyltlJ+1 DdtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709675447; x=1710280247; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mNaPcD8C1CaGfR8dSQp5MOtj1v2kWxS0AYvgOxX1T3o=; b=kT6R1zVijRxNgzRNlFoSvSoYAL0c1TlSrkVFG8Uar5NHs/DNTVPHnZ5V/ZzaCbjCFt +fe9+UFoHFOU+JHP1tjAtgmSAdmMiiGx+/f4Rd1ceKytW5K8aLlli2vF+aWfZA6fIGDn HOPGnAIhHiVOQ6BBBpYdypOJb0QRsSWlk9b1mFa5Q9OsrzY+QRMSEyhpN9D0F7G0OaOE vT52V9cNULBbwUuEODEKBCL3b7+FTgH9T5xgiKo6S0maax93Ub+w2ddGSTlo3orzo8ER x/we01l6LHZewIwKWCQ9n2T6jYDI7UXQVZg1AzIsxoo6Zckc5C/BgpPoiJAGUVVU0LAY KVeg== X-Forwarded-Encrypted: i=1; AJvYcCWvjgnZ8/gWNmUojdJNf0DDbBqw4hHFTaDIJp3U+YMdvcl27hO/gswW129b2uoVpn3eIIBqamovAxO9prZxyCuGC0h6VT6oDGj0l38dlFsM2S9e X-Gm-Message-State: AOJu0Yxt15c7mckN0CmdZtvw1g0wyHXLjNh0qBaUhyNBN4ViCitHCBPS BoeoLOgwgMu9K3fVShOVsTbpz3hWK6JSVzRvdwpckP1HJ3H1Qssz X-Google-Smtp-Source: AGHT+IHdCjid+xLiH0N/MR9dulpJN3363ay18STDBg1GfhIcNggZZwkEOJ9HYlaGyk7UYS0xT1qHvA== X-Received: by 2002:a6b:3e88:0:b0:7c8:3bd8:28be with SMTP id l130-20020a6b3e88000000b007c83bd828bemr10834256ioa.12.1709675446996; Tue, 05 Mar 2024 13:50:46 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id a2-20020a056638018200b00474f3cb7ec1sm1180525jaq.87.2024.03.05.13.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 13:50:46 -0800 (PST) Date: Tue, 5 Mar 2024 15:50:44 -0600 From: Nathan Bossart To: Michael Banck Cc: Tomas Vondra , Abhijit Menon-Sen , pgsql-hackers@lists.postgresql.org, =?utf-8?B?5oiQ5LmL54SV?= Subject: Re: [PATCH] Exponential backoff for auth_delay Message-ID: <20240305215044.GA3538518@nathanxps13> References: <658c4eab.050a0220.731ff.011e@mx.google.com> <65965e9d.050a0220.919a6.f9e1@mx.google.com> <65aa8265.170a0220.1ecef.91df@mx.google.com> <65aa8439.050a0220.31e77.0071@mx.google.com> <65e62440.170a0220.f6a7c.6f7f@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <65e62440.170a0220.f6a7c.6f7f@mx.google.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 04, 2024 at 08:42:55PM +0100, Michael Banck wrote: > On Wed, Feb 21, 2024 at 10:26:11PM +0100, Tomas Vondra wrote: >> I think it'd be good to consider: >> >> - Making the acr_array a hash table, and larger than 50 entries (I >> wonder if that should be dynamic / customizable by GUC?). > > I would say a GUC should be overkill for this as this would mostly be an > implementation detail. > > More generally, I think now that entries are expired (see below), this > should be less of a concern, so I have not changed this to a hash table > for now but doubled MAX_CONN_RECORDS to 100 entries. I don't have a strong opinion about making this configurable, but I do think we should consider making this a hash table so that we can set MAX_CONN_RECORDS much higher. Also, since these records are stored in shared memory, don't we need to lock them when searching/updating? > +static void > +auth_delay_init_state(void *ptr) > +{ > + Size shm_size; > + AuthConnRecord *array = (AuthConnRecord *) ptr; > + > + shm_size = sizeof(AuthConnRecord) * MAX_CONN_RECORDS; > + > + memset(array, 0, shm_size); > +} > + > +static void > +auth_delay_shmem_startup(void) > +{ > + bool found; > + Size shm_size; > + > + if (shmem_startup_next) > + shmem_startup_next(); > + > + shm_size = sizeof(AuthConnRecord) * MAX_CONN_RECORDS; > + acr_array = GetNamedDSMSegment("auth_delay", shm_size, auth_delay_init_state, &found); > +} Great to see the DSM registry getting some use. This example makes me wonder whether the size of the segment should be passed to the init_callback. > /* > * Module Load Callback > */ > void > _PG_init(void) > { > + if (!process_shared_preload_libraries_in_progress) > + ereport(ERROR, > + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), > + errmsg("auth_delay must be loaded via shared_preload_libraries"))); > + This change seems like a good idea independent of this feature. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com