Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 23c13ca

Browse files
jchampioCommitfest Bot
authored and
Commitfest Bot
committed
squash! Report external auth calls as wait events
Add a wait event around all calls to ldap_unbind(). (For the record, I do not want to implement this in this way.)
1 parent f1f8ea3 commit 23c13ca

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/backend/libpq/auth.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,9 @@ InitializeLDAPConnection(Port *port, LDAP **ldap)
23762376
(errmsg("could not set LDAP protocol version: %s",
23772377
ldap_err2string(r)),
23782378
errdetail_for_ldap(*ldap)));
2379+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_AFTER_SET_OPTION);
23792380
ldap_unbind(*ldap);
2381+
pgstat_report_wait_end();
23802382
return STATUS_ERROR;
23812383
}
23822384

@@ -2396,7 +2398,9 @@ InitializeLDAPConnection(Port *port, LDAP **ldap)
23962398
(errmsg("could not start LDAP TLS session: %s",
23972399
ldap_err2string(r)),
23982400
errdetail_for_ldap(*ldap)));
2401+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_AFTER_START_TLS);
23992402
ldap_unbind(*ldap);
2403+
pgstat_report_wait_end();
24002404
return STATUS_ERROR;
24012405
}
24022406
}
@@ -2540,7 +2544,9 @@ CheckLDAPAuth(Port *port)
25402544
{
25412545
ereport(LOG,
25422546
(errmsg("invalid character in user name for LDAP authentication")));
2547+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_AFTER_NAME_CHECK);
25432548
ldap_unbind(ldap);
2549+
pgstat_report_wait_end();
25442550
pfree(passwd);
25452551
return STATUS_ERROR;
25462552
}
@@ -2564,7 +2570,9 @@ CheckLDAPAuth(Port *port)
25642570
server_name,
25652571
ldap_err2string(r)),
25662572
errdetail_for_ldap(ldap)));
2573+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_AFTER_BIND_FOR_SEARCH);
25672574
ldap_unbind(ldap);
2575+
pgstat_report_wait_end();
25682576
pfree(passwd);
25692577
return STATUS_ERROR;
25702578
}
@@ -2597,7 +2605,9 @@ CheckLDAPAuth(Port *port)
25972605
errdetail_for_ldap(ldap)));
25982606
if (search_message != NULL)
25992607
ldap_msgfree(search_message);
2608+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_AFTER_SEARCH);
26002609
ldap_unbind(ldap);
2610+
pgstat_report_wait_end();
26012611
pfree(passwd);
26022612
pfree(filter);
26032613
return STATUS_ERROR;
@@ -2619,7 +2629,9 @@ CheckLDAPAuth(Port *port)
26192629
count,
26202630
filter, server_name, count)));
26212631

2632+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_AFTER_COUNT_ENTRIES);
26222633
ldap_unbind(ldap);
2634+
pgstat_report_wait_end();
26232635
pfree(passwd);
26242636
pfree(filter);
26252637
ldap_msgfree(search_message);
@@ -2638,7 +2650,9 @@ CheckLDAPAuth(Port *port)
26382650
filter, server_name,
26392651
ldap_err2string(error)),
26402652
errdetail_for_ldap(ldap)));
2653+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_AFTER_GET_DN);
26412654
ldap_unbind(ldap);
2655+
pgstat_report_wait_end();
26422656
pfree(passwd);
26432657
pfree(filter);
26442658
ldap_msgfree(search_message);
@@ -2666,7 +2680,9 @@ CheckLDAPAuth(Port *port)
26662680
(errmsg("LDAP login failed for user \"%s\" on server \"%s\": %s",
26672681
fulluser, server_name, ldap_err2string(r)),
26682682
errdetail_for_ldap(ldap)));
2683+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_AFTER_BIND);
26692684
ldap_unbind(ldap);
2685+
pgstat_report_wait_end();
26702686
pfree(passwd);
26712687
pfree(fulluser);
26722688
return STATUS_ERROR;
@@ -2675,7 +2691,9 @@ CheckLDAPAuth(Port *port)
26752691
/* Save the original bind DN as the authenticated identity. */
26762692
set_authn_id(port, fulluser);
26772693

2694+
pgstat_report_wait_start(WAIT_EVENT_LDAP_UNBIND_SUCCESS);
26782695
ldap_unbind(ldap);
2696+
pgstat_report_wait_end();
26792697
pfree(passwd);
26802698
pfree(fulluser);
26812699

src/backend/utils/activity/wait_event_names.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ LDAP_BIND_FOR_SEARCH "Waiting for an LDAP bind operation to search the directory
178178
LDAP_HOST_LOOKUP "Waiting for DNS lookup of LDAP servers."
179179
LDAP_SEARCH "Waiting for an LDAP search operation to complete."
180180
LDAP_START_TLS "Waiting for an LDAP StartTLS exchange."
181+
LDAP_UNBIND_AFTER_BIND "Waiting for an LDAP connection to be unbound after a simple bind failed."
182+
LDAP_UNBIND_AFTER_BIND_FOR_SEARCH "Waiting for an LDAP connection to be unbound after a bind for search failed."
183+
LDAP_UNBIND_AFTER_COUNT_ENTRIES "Waiting for an LDAP connection to be unbound after an entry count failed."
184+
LDAP_UNBIND_AFTER_GET_DN "Waiting for an LDAP connection to be unbound after ldap_get_dn failed."
185+
LDAP_UNBIND_AFTER_NAME_CHECK "Waiting for an LDAP connection to be unbound after a name check failed."
186+
LDAP_UNBIND_AFTER_SEARCH "Waiting for an LDAP connection to be unbound after a bind+search failed."
187+
LDAP_UNBIND_AFTER_SET_OPTION "Waiting for an LDAP connection to be unbound after ldap_set_option failed."
188+
LDAP_UNBIND_AFTER_START_TLS "Waiting for an LDAP connection to be unbound after ldap_start_tls_s failed."
189+
LDAP_UNBIND_SUCCESS "Waiting for a successful LDAP connection to be unbound."
181190
PAM_ACCT_MGMT "Waiting for the PAM service to validate the user account."
182191
PAM_AUTHENTICATE "Waiting for the PAM service to authenticate the user."
183192
RADIUS_RECVFROM "Waiting for a <function>recvfrom</function> call during a RADIUS transaction."

0 commit comments

Comments
 (0)