Page MenuHomePhabricator

[upstream] [worked around] nginx fails: could not build the types_hash
Closed, ResolvedPublic

Description

On labs nginx refuse to start out:

Restarting nginx: nginx: [emerg] could not build the types_hash, you should increase either types_hash_max_size: 1024 or types_hash_bucket_size: 32

Nginx loads the mime type in a hash which has the mime name for keys, one of the keys is 36 bytes long which does not fit the 32 bytes limit.

The limit itself is set by Nginx on startup and attempt to match the CPU cache line. It does so by looking up the processor vendor / model and set the name.

The lookup code is src/core/ngx_cpuinfo.c , function ngx_cpuinfo()

For vendor 'GenuineIntel':

family 5 > cache line is 32
family 6 > cache line is 32 or 64 bits depending on model
family 15 > cache line is 128

In production we are using Intel Xeon which cpu info reports as:

vendor_id : GenuineIntel
cpu family : 6
model : 30
stepping : 5
cache_alignement: 64

Given the model, I am assuming nginx finds out 64.

In labs:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 2
model name : QEMU Virtual CPU version 1.0
stepping : 3
microcode : 0x1
cpu MHz : 2659.998
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 4
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm up rep_good nopl pni vmx cx16 popcnt hypervisor lahf_lm
bogomips : 5319.99
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:

Given the low model, we end up with a cache line of 32 bytes.

If cache_alignment (64) is the cache line size, that should have been the value retained by Nginx.

Anyway, the mime type hash ends up being 32 bytes which is too small to hold the longest mime type names.

The workaround is to set types_hash_bucket_size at 64.

We are using Nginx 1.1.19 from Ubuntu Precise.


Version: unspecified
Severity: minor
See Also:
http://trac.nginx.org/nginx/ticket/352

Details

Reference
bz48210

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:18 AM
bzimport set Reference to bz48210.
bzimport added a subscriber: Unknown Object (MLST).

Nginx 1.4.1 and 1.5.0 have the same code so they are most probably affected as well.

Related URL: https://gerrit.wikimedia.org/r/62603 (Gerrit Change Ieddf98ffae1a97aa1b533726453232a06f765bd2)

Worked around by above change which is to hardcode the value to 64 whenever nginx is installed on labs. Lowering priority and unassigning myself.

Tweaking the bucket sizes solved the issue.