You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The calculation of server_names_hash_bucket_size underestimates the required size.
With a long name (49 characters) I hit:
2017/04/19 02:01:08 [emerg] 28#28: could not build server_names_hash, you should increase server_names_hash_bucket_size: 64
nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 64
nginx: configuration file /tmp/nginx-cfg540721084 test failed
I confirmed in that temp file that server_names_hash_bucket_size is indeed set to 64.
@aledbf right, but I think there's some extra nginx padding in the hash table that isn't accounted for. This is just on the length (i.e. key-size) as well - I haven't hit the total hash table size yet.
If in doubt, try creating an ingress with a host with 49 characters e.g.
The calculation of server_names_hash_bucket_size underestimates the required size.
With a long name (49 characters) I hit:
I confirmed in that temp file that
server_names_hash_bucket_size
is indeed set to 64.Here is the relevant code:
https://github.com/nginx/nginx/blob/master/src/core/ngx_hash.c#L269
The correct calculation is
NGX_HASH_ELT_SIZE(&names[n]) + sizeof(void *)
where
NGX_HASH_ELT_SIZE(name)
=(sizeof(void *) + ngx_align((name)->key.len + 2, sizeof(void *)))
So for us, assuming 64 bit, we want to do
8 + 8 + align8(len(s) + 2)
My 49 characters therefore, is
16 + align8(51) = 16 + 56 = 72
(and of course we then have to round up to the next power of 2, i.e. 128)The text was updated successfully, but these errors were encountered: