Rails action being called twice in single request

I’ve got a really strange bug and I’m not sure what could be causing it.

I’m stress testing a rails 3 app running under jruby/trinidad. Under
load I start to see a controller action called twice for the same http
request. This is a rails metal controller. We have a couple of other
non metal controllers that I don’t see the same behavior in.

More confirmation that the action is being called twice is that we use
instrumentation, and ‘process_action.action_controller’ is being sent
twice in the same request to the subscriber. Also, the logging
statements added internally by rails only show once in the logs. In
addition the client is a custom load testing client that has very
verbose logging, so I’d see it if the client was sending the request

This usually starts happening when I have around 50-100 concurrent
requests. When it’s not loaded I don’t see this behavior.

I started logging the thread id, and it’s not different threads
executing the action, it’s the same thread executing the action twice.

Any idea what could be causing this?