#1347 Fix hub startup handling
Merged 5 years ago by mikem. Opened 5 years ago by mikem.

file modified
+3
@@ -10,6 +10,9 @@ 

      WSGIApplicationGroup %{GLOBAL}

      # ^ works around a hub issue with OpenSSL

      # see: https://cryptography.io/en/latest/faq/#starting-cryptography-using-mod-wsgi-produces-an-internalerror-during-a-call-in-register-osrandom-engine

+     WSGIScriptReloading Off

+     # ^ reloading breaks hub "firstcall" check

+     # see: https://pagure.io/koji/issue/875

      <IfVersion < 2.4>

          Order allow,deny

          Allow from all

file modified
+7 -2
@@ -27,6 +27,7 @@ 

  import os

  import sys

  import time

+ import threading

  import traceback

  import pprint

  import resource
@@ -691,12 +692,16 @@ 

  #

  

  firstcall = True

+ firstcall_lock = threading.Lock()

  

  def application(environ, start_response):

      global firstcall

      if firstcall:

-         server_setup(environ)

-         firstcall = False

+         with firstcall_lock:

+             # check again, another thread may be ahead of us

+             if firstcall:

+                 server_setup(environ)

+                 firstcall = False

      # XMLRPC uses POST only. Reject anything else

      if environ['REQUEST_METHOD'] != 'POST':

          headers = [

Fixes: #875

In some environments, module loading can break after restarts. Here we take two steps to prevent that:

  • disable mod_wsgi auto reloading
  • use a thread lock for the server setup that happens on first call

I have a koji install that yesterday was reliably exhibiting symptoms within 30 minutes of starting the hub.

Applied this patch to kojixmlrpc and turned off auto_reloading and the hub has been running uninterrupted for almost 8 hours.

:thumbsup:

Commit 58ff256 fixes this pull-request

Pull-Request has been merged by mikem

5 years ago
Metadata