From 5fd86869f32b074dcd31a9932a93cde9d56efa68 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 22 Mar 2024 18:08:50 +0000 Subject: [PATCH] ITS#10191 back-mdb: check for pool pause in search Also related, cancel any ops on a DB that is being deleted. --- servers/slapd/back-mdb/search.c | 10 ++++++++++ servers/slapd/bconfig.c | 1 + servers/slapd/connection.c | 22 ++++++++++++++++++++++ servers/slapd/proto-slap.h | 1 + 4 files changed, 34 insertions(+) diff --git a/servers/slapd/back-mdb/search.c b/servers/slapd/back-mdb/search.c index 03549a7c3b..416f227fe6 100644 --- a/servers/slapd/back-mdb/search.c +++ b/servers/slapd/back-mdb/search.c @@ -416,6 +416,8 @@ mdb_waitfixup( Operation *op, ww_ctx *ww, MDB_cursor *mci, MDB_cursor *mcd, IdSc return rc; } +#define PAUSEPOLL 100 + int mdb_search( Operation *op, SlapReply *rs ) { @@ -433,6 +435,7 @@ mdb_search( Operation *op, SlapReply *rs ) int manageDSAit; int tentries = 0; int admincheck = 0; + int pausepoll; IdScopes isc; MDB_cursor *mci, *mcd; ww_ctx wwctx; @@ -806,6 +809,7 @@ adminlimit: id = mdb_idl_first( candidates, &cursor ); } + pausepoll = 0; while (id != NOID) { int scopeok; @@ -813,6 +817,12 @@ adminlimit: loop_begin: + if ( ++pausepoll == PAUSEPOLL ) { + pausepoll = 0; + if ( ldap_pvt_thread_pool_pausing( &connection_pool ) > 0 ) + ldap_pvt_thread_pool_pausewait( &connection_pool ); + } + /* check for abandon */ if ( op->o_abandon ) { rs->sr_err = SLAPD_ABANDON; diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 06b222cdba..a5ff9c127e 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -6931,6 +6931,7 @@ config_back_delete( Operation *op, SlapReply *rs ) if ( ce->ce_be->bd_info->bi_db_close ) { ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL ); } + connections_drop_db( ce->ce_be ); backend_destroy_one( ce->ce_be, 1); } diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 073e7a33c2..e93db060d3 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -254,6 +254,28 @@ void connections_drop() connection_done( c ); } +/* Drop all ops for given database */ +void connections_drop_db( BackendDB *be ) +{ + Operation *o; + Connection* c; + ber_socket_t connindex; + BackendDB *rbe = be->bd_self; + + for( c = connection_first( &connindex ); + c != NULL; + c = connection_next( c, &connindex ) ) + { + for ( o = LDAP_STAILQ_FIRST( &c->c_ops ); o; o = LDAP_STAILQ_NEXT( o, o_next )) { + if ( o->o_bd && o->o_bd->bd_self == rbe ) { + o->o_abandon = 1; + o->o_cancel = 1; + } + } + } + connection_done( c ); +} + static Connection* connection_get( ber_socket_t s ) { Connection *c; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 8e0d184e44..a11503fd00 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -757,6 +757,7 @@ LDAP_SLAPD_F (int) connections_shutdown LDAP_P((void)); LDAP_SLAPD_F (int) connections_destroy LDAP_P((void)); LDAP_SLAPD_F (int) connections_timeout_idle LDAP_P((time_t)); LDAP_SLAPD_F (void) connections_drop LDAP_P((void)); +LDAP_SLAPD_F (void) connections_drop_db LDAP_P(( BackendDB *be )); LDAP_SLAPD_F (Connection *) connection_client_setup LDAP_P(( ber_socket_t s, -- 2.47.3