httpd icon indicating copy to clipboard operation
httpd copied to clipboard

Rewrite of mod_unique_id:

Open atlesn opened this issue 3 years ago • 4 comments

The old implementation has multiple issues also when the latest counter-modification is taken into account.

The old module was a bit difficult to understand with a lot of extra logic doing byte per byte operations "manually". I'm proposing a new structure to the whole module which is easier to modify.

The actual problem with uniqueness cannot be solved as intended by the original authors 20+ years ago. This implementation used IP-addresses inside the unique ID, this has since been removed.

Maybe a configuration parameter could provide a server ID (set manually) which can be used inside the string.

I'm also unsure about this "Thread ID" parameter, I haven't found any reliable source for this parameter. Currently a truncated pointer is used.

  • Use Process ID, Thread ID, Timestamp, 16-bit per thread counter and 16 random bits
  • Use provided library function for encoding base64
  • Use packed struct instead of addressing each member manually in and index
  • Use global counter /only/ if threads are not being used
  • General re-structuring of functions
  • Initialize counters on demand, remove two init functions
  • Straight forward to change the build-up of the unique ID parameters after discussion.
  • TODO : Add endian conversion, find better thread ID

atlesn avatar May 04 '21 12:05 atlesn

Which byte swap functions should be used for the fixed width types that work on all platforms and that preferably are used elsewhere in the code?

atlesn avatar May 05 '21 10:05 atlesn

I've added the configuration parameter UniqueIdServerId which is used to ensure uniqueness across different servers. I've also implemented byte swapping and changed the method of retrieving a thread ID.

atlesn avatar May 14 '21 15:05 atlesn

@atlesn You might be interested in some of the conversation taking place on this bugid: https://bz.apache.org/bugzilla/show_bug.cgi?id=65159

wjcarpenter avatar Aug 19 '21 17:08 wjcarpenter

@wjcarpenter Thanks, I can see that somebody linked in this PR there as well. I've also posted this diff on bugzilla https://bz.apache.org/bugzilla/show_bug.cgi?id=65307

atlesn avatar Aug 20 '21 20:08 atlesn