Skip to content

Body duplication when using the ExtProc filter and enabling retry policy #45470

@Zagitori

Description

@Zagitori

Title: Body duplication when using the ExtProc filter and enabling retry policy

Description:
Envoy version: 1.35.6
When using the ExtProc filter with requestBodyProcessingMode=FULL_DUPLEX_STREAMED, the request body is duplicated when retries are enabled.

ExtProc server request processing flow:

  1. Receive RequestHeaders request
  2. Receive RequestBody requests
  3. Receive RequestTrailers request
  4. Send RequestHeaders response (with mutation)
  5. Send RequestBody responses (chunks unchanged)
  6. Send RequestTrailers response (trailers unchanged)

The logs show that the http.router terminal filter receives the body two times:
... [ext_proc] Received request headers response
... [ext_proc] applying headers response. body mode = FULL_DUPLEX_STREAMED
... [ext_proc] Applying header mutations
... [ext_proc] Finish external processing call
... [ext_proc] Received request body response
... [ext_proc] Processing body response
... [ext_proc] FULL_DUPLEX_STREAMED body response is received and body_mode_: FULL_DUPLEX_STREAMED
... [ext_proc] Injecting 24 bytes of data to filter stream in FULL_DUPLEX_STREAMED mode. end_of_stream is false
... [router] router decoding headers: ...
... [router] router decoding data: 24
... [ext_proc] Finish external processing call
... [ext_proc] Received request trailers response
... [ext_proc] Applying response to buffered trailers, body_mode_ FULL_DUPLEX_STREAMED
... [ext_proc] Finish external processing call
... [ext_proc] Continue processing
... [router] router decoding data: 24
... [router] router decoding trailers: ...

The logs show the following:

  1. ExtProc receives chunks and forwards them to the upstream http.router filter.
  2. The router sends the data and buffers it, as retries are enabled.
  3. ExtProc receives the trailers and calls continueDecoding.
  4. ContinueDecoding calls decodeData, passing the buffer containing the request body as data.
  5. The router sends the data from the buffer that has already been sent.

A similar problem was described in #36119.
I am using a newer version but the problem still exists.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions