Skip to content

Fix Elasticsearch BadRequest exception

Dmitry Gruzd requested to merge fix-elastic-transport-error into master

What does this MR do?

This is a fix for a change behind a feature flag elasticsearch_use_routing. Introduced in !22261 (merged)

While working on #196569 (comment 281186673) we met an unexpected exception

[400] {"error":{"root_cause":[{"type":"too_long_frame_exception","reason":"An HTTP line is larger than 4096 bytes."}],"type":"too_long_frame_exception","reason":"An HTTP line is larger than 4096 bytes."},"status":400}

I'm still waiting for rails c access on staging, so my guess is that we push too many project_ids to routing and http URI becomes too long resulting in the ES transport exception.


This MR sets a limit to prevent this kind of errors.

Calculation of a new limit

The worst possible case:

  • each project_id is 10 digit long (close to the max 4-byte integer size >= 2,000,000,000)

That way we have 19 bytes per project_id ("project_2147483647,".length => 19)

We want to make room for schema, login-password, path. Let's say we over reserve 512 bytes, we have 4096-512=3584 bytes left.

3584/19 = 188 project_ids. Let's round it to the closest power of 2 - 128.


Does this MR meet the acceptance criteria?


Availability and Testing


If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports