Monday, October 1, 2012

Why Nginx kept Riak's secondary indexes(2i) from working

Riak recently introduced Secondary Indexes (a.k.a. 2i). 2i allows objects in Riak to be stored with additional queryable values. At Validas we have leveraged 2i for validating uniqueness instead of relying on MapReduce or RiakSearch to perform the check, among other things. This worked great for us in our local dev environment.

Unfortunately when we deployed to our staging environment any feature that leveraged 2i failed to work. We spent a good amount of time reviewing our specs and feature implementation, but everything checked out fine so we moved on to our Riak app.config, comparing line for line the staging and development configuration. This did not produce any answers either.

Eventually we landed at our load balancer, Nginx. When we bypassed Nginx 2i worked perfectly! We could add an index to an object and then find the object by searching for the indexed value. We were able to determine that Nginx was removing the index header information from our request.

Not sure why Nginx was squashing a seemingly innocent 2i header and not other Riak specific headers, we ran across this post ... How to get non standard http headers on Nginx. Nginx by default removes header that use underscores.

As you can see here, Riak depends on underscores for managing secondary indexes as it suffixes the index name with '_bin'.
That same post generously linked to Nginx: underscores in headers which shows you how to modify your Nginx config and allow underscores in headers. Once we made that change, all of our Riak 2i features worked flawlessly!

Hopefully if you have this problem you find this blog post in less time than it took us to troubleshoot!

1 comment:

  1. We are getting different type of stories on pastille salon spa for yana event. That's done really well and interesting for more stories. Thank you so much for all your great featuresmukbang asmr