Re: LDAP timeout options - Mailing list pgsql-hackers

From Zsolt Parragi
Subject Re: LDAP timeout options
Date
Msg-id CAN4CZFMe8zzGzxRKeRYF6ajR4fzqu=Oi12e4eU3fDNAP4V7_3Q@mail.gmail.com
Whole thread
In response to LDAP timeout options  (Roman Khapov <rkhapov@yandex-team.ru>)
List pgsql-hackers
Hello

+#ifdef WIN32
+    option = (ULONG) port->hba->ldaptimeout;
+    if (port->hba->ldaptimeout != LDAP_NO_LIMIT
+        && (r = ldap_set_option(*ldap, LDAP_OPT_TIMELIMIT, &option)) != LDAP_SUCCESS)
+#else

According to [1] LDAP_OPT_TIMELIMIT "A limit on the number of seconds
the server will wait to complete a bind. This also specifies the limit
on the number of seconds the server spends on a search." The patch
documentation states:

+       Maximum time in seconds to wait for the completion of a
+       synchronous LDAP operation, such as a search or bind request.
+       A value of 0 disables the timeout.  If not specified, the
+       behavior depends on the LDAP client library configuration
+       (typically no timeout).

To me this reads that if I specify this setting alone (without the
other), this timeout value should save me from timeouts from
synchronous operations. But based on the Microsoft documentation, it
doesn't: it still requires a reachable LDAP server, and it only limits
how much time the server spends on the operation.

+    if (port->hba->ldapnetworktimeout != -1
+        && (r = ldap_set_option(*ldap, LDAP_OPT_NETWORK_TIMEOUT, &tv)) !=
LDAP_SUCCESS)

and

+        Maximum time in seconds to wait for a response from the LDAP
+        server when establishing a connection or waiting for data on an
+        existing connection.  A value of 0 disables the timeout.

On non-windows the disabling value is -1, which can't be specified
because the validator rejects it:

+        REQUIRE_AUTH_OPTION(uaLDAP, "ldaptimeout", "ldap");
+        long_val = strtol(val, &endp, 10);
+        if (endp == val || long_val > INT_MAX || long_val < 0)
+        {
+            ereport(elevel,

Is a step mapping 0 to -1 missing from the non win32 branch?

[1] :  https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ldap/session-options



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: index prefetching
Next
From: Peter Travers
Date:
Subject: [PATCH] proposal to surface index used by replica identity