Bug 65307 - Rewrite and improvements of mod_unique_id
Summary: Rewrite and improvements of mod_unique_id
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_unique_id (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-14 16:25 UTC by Atle Solbakken
Modified: 2021-05-14 16:25 UTC (History)
0 users



Attachments
Diff for mod_unique_id.c (23.05 KB, patch)
2021-05-14 16:25 UTC, Atle Solbakken
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Atle Solbakken 2021-05-14 16:25:07 UTC
Created attachment 37862 [details]
Diff for mod_unique_id.c

Hi

I've been working on some cleanups in mod_unique_id module and have also changed the composition of values used to ensure unique IDs.

There has recently there has been a bug report #65159 which was resolved by replacing a global counter with a per-thread counter. This is however not enough to ensure uniqueness in all situations.

The cleanup is mostly done because the current module has been patched multiple times over the years and it was kind of messy and difficult to work with.

I'm proposing new data to include in the unique ID string:

- 32 bit process ID
- 64 bit thread ID
- 64 bit timestamp in microseconds
- 16 bit server ID
- 16 bit counter

The server ID is by default 0 but can be set to a fixed value in the configuration. This way an ID can be assigned to different servers for instance when doing load balancing with a common backend.

The 16 bit counter is per-thread (as in the previous patch) and ensures uniqueness should the timestamp be the same in two requests.

There are no random numbers.

All values are swapped to network byte order.

The total length of the unique string has been increased from 27 to 32 characters.

It is nevertheless easy with this patch to change the actual composition of values in the unique ID and I reckon there might be different opinions on this.

The attached diff changes the whole file, it might be easier to read the file whole itself:

https://github.com/apache/httpd/blob/a477b27e2fc74b1a41f8e600c599d89454a5cd38/modules/metadata/mod_unique_id.c

Best regards
Atle