GNU bug report logs - #29466
[PATCH] services: web: Add support for configuring the nginx server names hash.

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Mon, 27 Nov 2017 08:25:01 UTC

Severity: normal

Tags: patch

Done: Christopher Baines <mail <at> cbaines.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Christopher Baines <mail <at> cbaines.net>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#29466: closed ([PATCH] services: web: Add support for
 configuring the nginx server names hash.)
Date: Mon, 11 Dec 2017 21:02:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 11 Dec 2017 21:01:22 +0000
with message-id <87wp1t568t.fsf <at> cbaines.net>
and subject line Re: [bug#29466] [PATCH 1/2] services: web: Switch nginx related functions to use match-record.
has caused the debbugs.gnu.org bug report #29466,
regarding [PATCH] services: web: Add support for configuring the nginx server names hash.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
29466: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29466
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Christopher Baines <mail <at> cbaines.net>
To: guix-patches <at> gnu.org
Subject: [PATCH] services: web: Add support for configuring the nginx server
 names hash.
Date: Mon, 27 Nov 2017 08:23:38 +0000
The nginx service can fail to start if the server names hash bucket size is
too small, which can happen on some systems, and when using QEMU, depending on
the CPU.

* gnu/services/web.scm (<nginx-configuration>): Add
  server-names-hash-bucket-size and server-names-hash-bucket-max-size.
  (default-nginx-config): Add support for the new hash bucket size parameters.
  (nginx-service, nginx-activation): Pass the new hash bucket size parameters
  through to the default-nginx-config procedure.
* doc/guix.texi (Web Services): Document the new hash bucket size parameters.
---
 doc/guix.texi        |  7 +++++++
 gnu/services/web.scm | 36 +++++++++++++++++++++++++++++++-----
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 2a6825682..d0a00bdcb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14874,6 +14874,13 @@ This can be useful if you have an existing configuration file, or it's
 not possible to do what is required through the other parts of the
 nginx-configuration record.
 
+@item @code{server-names-hash-bucket-size} (default: @code{#f})
+Bucket size for the server names hash tables, defaults to @code{#f} to
+use the size of the processors cache line.
+
+@item @code{server-names-hash-bucket-max-size} (default: @code{#f})
+Maximum bucket size for the server names hash tables.
+
 @end table
 @end deffn
 
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 9d713003c..b9acee762 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -38,6 +38,8 @@
             nginx-configuration-run-directory
             nginx-configuration-server-blocks
             nginx-configuration-upstream-blocks
+            nginx-configuration-server-names-hash-bucket-size
+            nginx-configuration-server-names-hash-bucket-max-size
             nginx-configuration-file
 
             <nginx-server-configuration>
@@ -141,6 +143,10 @@
                  (default '()))          ;list of <nginx-server-configuration>
   (upstream-blocks nginx-configuration-upstream-blocks
                    (default '()))      ;list of <nginx-upstream-configuration>
+  (server-names-hash-bucket-size nginx-configuration-server-names-hash-bucket-size
+                                 (default #f))
+  (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size
+                                     (default #f))
   (file          nginx-configuration-file         ;#f | string | file-like
                  (default #f)))
 
@@ -235,7 +241,9 @@ of index files."
         (cons head out)))
   (fold-right flatten1 '() lst))
 
-(define (default-nginx-config nginx log-directory run-directory server-list upstream-list)
+(define (default-nginx-config nginx log-directory run-directory server-list
+                              upstream-list server-names-hash-bucket-size
+                              server-names-hash-bucket-max-size)
   (apply mixed-text-file "nginx.conf"
          (flatten
           "user nginx nginx;\n"
@@ -249,6 +257,18 @@ of index files."
           "    scgi_temp_path " run-directory "/scgi_temp;\n"
           "    access_log " log-directory "/access.log;\n"
           "    include " nginx "/share/nginx/conf/mime.types;\n"
+          (if server-names-hash-bucket-size
+              (string-append
+               "    server_names_hash_bucket_size "
+               (number->string server-names-hash-bucket-size)
+               ";\n")
+              "")
+          (if server-names-hash-bucket-max-size
+              (string-append
+               "    server_names_hash_bucket_max_size "
+               (number->string server-names-hash-bucket-max-size)
+               ";\n")
+              "")
           "\n"
           (map emit-nginx-upstream-config upstream-list)
           (map emit-nginx-server-config server-list)
@@ -268,7 +288,8 @@ of index files."
 (define nginx-activation
   (match-lambda
     (($ <nginx-configuration> nginx log-directory run-directory server-blocks
-                              upstream-blocks file)
+                              upstream-blocks server-names-hash-bucket-size
+                              server-names-hash-bucket-max-size file)
      #~(begin
          (use-modules (guix build utils))
 
@@ -289,13 +310,16 @@ of index files."
          (system* (string-append #$nginx "/sbin/nginx")
                   "-c" #$(or file
                              (default-nginx-config nginx log-directory
-                               run-directory server-blocks upstream-blocks))
+                               run-directory server-blocks upstream-blocks
+                               server-names-hash-bucket-size
+                               server-names-hash-bucket-max-size))
                   "-t")))))
 
 (define nginx-shepherd-service
   (match-lambda
     (($ <nginx-configuration> nginx log-directory run-directory server-blocks
-                              upstream-blocks file)
+                              upstream-blocks server-names-hash-bucket-size
+                              server-names-hash-bucket-max-size file)
      (let* ((nginx-binary (file-append nginx "/sbin/nginx"))
             (nginx-action
              (lambda args
@@ -304,7 +328,9 @@ of index files."
                     (system* #$nginx-binary "-c"
                              #$(or file
                                    (default-nginx-config nginx log-directory
-                                     run-directory server-blocks upstream-blocks))
+                                     run-directory server-blocks upstream-blocks
+                                     server-names-hash-bucket-size
+                                     server-names-hash-bucket-max-size))
                              #$@args))))))
 
        ;; TODO: Add 'reload' action.
-- 
2.14.2



[Message part 3 (message/rfc822, inline)]
From: Christopher Baines <mail <at> cbaines.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 29466-done <at> debbugs.gnu.org
Subject: Re: [bug#29466] [PATCH 1/2] services: web: Switch nginx related
 functions to use match-record.
Date: Mon, 11 Dec 2017 21:01:22 +0000
[Message part 4 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Christopher Baines <mail <at> cbaines.net> skribis:
>
>> As this is less prone to mistakes than match.
>>
>> * gnu/services/web.scm (default-nginx-config, nginx-activation,
>>   nginx-shepherd-service): Switch from using match-lambda to match-record.
>
> Awesome.  LGTM!

Great, I've pushed this and the previous patch.

> PS: I’d rather let Clément or some other nginx-savvy person comment on
>     the second patch.

Yeah, that's fine :) I'll close this bug anyway, as the remaining patch
I sent is not anywhere near ready yet.
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 7 years and 222 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.