From: Bill Erickson Date: Tue, 22 Nov 2022 20:50:43 +0000 (-0500) Subject: Revert "LP#1729610: Allow queuing (for a while) during child backlog" X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=69024a145bc932cfdeb95cb927abf7f19ba75e37;p=working%2FOpenSRF.git Revert "LP#1729610: Allow queuing (for a while) during child backlog" This reverts commit 0201ca954002eb241d277c3068659bb1f8100bab. --- diff --git a/src/perl/lib/OpenSRF/Server.pm b/src/perl/lib/OpenSRF/Server.pm index 52c53d2..dc1bd34 100644 --- a/src/perl/lib/OpenSRF/Server.pm +++ b/src/perl/lib/OpenSRF/Server.pm @@ -52,7 +52,6 @@ sub new { if $self->{stderr_log_path}; $self->{min_spare_children} ||= 0; - $self->{max_backlog_queue} ||= 1000; $self->{max_spare_children} = $self->{min_spare_children} + 1 if $self->{max_spare_children} and @@ -155,20 +154,13 @@ sub run { $self->register_routers; my $wait_time = 1; - my @max_children_msg_queue; - # main server loop while(1) { - my $from_network = 0; $self->check_status; $self->{child_died} = 0; - my $msg = shift(@max_children_msg_queue); - - # no pending message, so wait for the next one forever - $from_network = $wait_time = -1 if (!$msg); - $msg ||= $self->{osrf_handle}->process($wait_time); + my $msg = $self->{osrf_handle}->process($wait_time); !$from_network and $chatty and $logger->debug("server: attempting to process previously queued message"); $from_network and $chatty and $logger->internal("server: no queued messages, processing due to network or signal"); @@ -200,76 +192,11 @@ sub run { $logger->warn("server: no children available, waiting... consider increasing " . "max_children for this application higher than $self->{max_children} ". "in the OpenSRF configuration if this message occurs frequently"); + $self->check_status(1); # block until child is available - if ($from_network) { - $chatty and $logger->debug("server: queuing new message"); - push @max_children_msg_queue, $msg; - } else { - $chatty and $logger->debug("server: re-queuing old message"); - unshift @max_children_msg_queue, $msg; - } - - $logger->warn("server: backlog queue size is now ". scalar(@max_children_msg_queue)); - - if (@max_children_msg_queue < $self->{max_backlog_queue}) { - # We still have room on the queue. Set the wait time to - # 1s, waiting for a drone to be freed up and reprocess - # this (and any other) queued messages. - $wait_time = 1; - if (!$from_network) { - # if we got here, we had retrieved a message from the queue - # but couldn't process it... but also hadn't fetched any - # additional messages from the network. Doing so now, - # as otherwise only one message will ever get queued - $msg = $self->{osrf_handle}->process($wait_time); - if ($msg) { - $chatty and $logger->debug("server: queuing new message after a re-queue"); - push @max_children_msg_queue, $msg; - } - } - } else { - - if (!$from_network) { - # The queue is full, and we just requeued a message. We'll - # now see if there is a request available from the network; - # if so, we'll see if a child is available again or else - # drop it - $msg = $self->{osrf_handle}->process($wait_time); - if ($msg) { - $self->check_status(); - if (@{$self->{idle_list}}) { - # child now available, so we'll go ahead and queue it - $chatty and $logger->debug("server: queuing new message after a re-queue with a full queue"); - push @max_children_msg_queue, $msg; - } else { - # ok, need to drop this one - my $resp = OpenSRF::DomainObject::oilsMessage->new(); - $resp->type('STATUS'); - $resp->payload( - OpenSRF::DomainObject::oilsMethodException->new( - status => "Service unavailable: no available children and backlog queue at limit", - statusCode => STATUS_SERVICEUNAVAILABLE - ) - ); - $resp->threadTrace(1); - - $logger->set_osrf_xid($msg->osrf_xid); - $self->{osrf_handle}->send( - to => $msg->from, - osrf_xid => $msg->osrf_xid, # Note that this is ignored, which - # is why we called $logger->set_osrf_xid above. - # We probably don't want that to be necessary - # if osrf_xid is explicitly set here, but that'll - # be a FIXME for later - thread => $msg->thread, - body => OpenSRF::Utils::JSON->perl2JSON([ $resp ]) - ); - $logger->warn("Backlog queue full for $self->{service}; forced to drop message " . - $msg->thread . " from " . $msg->from); - } - } - } - } + my $child = pop(@{$self->{idle_list}}); + push(@{$self->{active_list}}, $child); + $self->write_child($child, $msg); } } else { diff --git a/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm b/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm index 766df6a..0a84ae1 100644 --- a/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm +++ b/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm @@ -379,8 +379,9 @@ sub flush_socket { my $self = shift; return 0 unless $self->connected; - while (my $excess = $self->wait(0)) { - $logger->info("flushing data from socket... $excess"); + while ($self->wait(0)) { + # TODO remove this log line + $logger->info("flushing data from socket..."); } return $self->connected;