This patch does appear to have solved the issue reported, but it
introduced another.
If I use `http-request add-header` with %rt in the value to add the
request ID, and then I also use it in `unique-id-format`, the 2 settings
get different values. the value used for`http-request add-header` will
be one less than the value used for `unique-id-format` (this applies to
both using %ID in the log format and using `unique-id-header`).

Without this patch, all values are the same.

-Patrick

------------------------------------------------------------------------
*From: *Willy Tarreau <w...@1wt.eu>
*Sent: * 2013-08-13 11:53:16 E
*To: *Patrick Hemmer <hapr...@stormcloud9.net>
*CC: *haproxy@formilux.org <haproxy@formilux.org>
*Subject: *Re: haproxy duplicate http_request_counter values

> Hi Patrick,
>
> On Sun, Aug 11, 2013 at 03:45:36PM -0400, Patrick Hemmer wrote:
>> I'm using the %rt field in the "unique-id-format" config parameter (the
>> full value is "%{+X}o%pid-%rt"), and am getting lots of duplicates. In
>> one specific case, haproxy added the same http_request_counter value to
>> 70 different http requests within a span of 61 seconds (from various
>> client hosts too). Does the http_request_counter only increment under
>> certain conditions, or is this a bug?
> Wow, congrats, you found a nice ugly bug! Here's how the counter is
> retrieved at the moment of logging :
>
>       iret = snprintf(tmplog, dst + maxsize - tmplog, "%04X", 
> global.req_count);
>
> As you can see, it uses a global variable which holds the global number of
> requests seen at the moment of logging (or assigning the header) instead of
> a unique value assigned to each request!
>
> So all the requests that are logged in the same time frame between two
> new requests get the same ID :-(
>
> The counter should be auto-incrementing so that each retrieval is unique.
>
> Please try with the attached patch.
>
> Thanks,
> Willy
>

Reply via email to