Skip to content

Fix randomness for correlation IDs

Mikhail Mazurskiy requested to merge ash2k/fix-randomness into master

Followup for !80 (merged).

In gitaly!2746 (merged) I'm trying to update Gitaly to use new functionality from !80 (merged) but ran into an issue where IDs are not random enough. In fact, they are identical if generated within one millisecond if my reading of code is correct. See https://gitlab.com/gitlab-org/gitaly/-/jobs/828950527#L2008:

=== RUN   TestGetCorrelationID/not_provided_in_context
    TestGetCorrelationID/not_provided_in_context: gitalyssh_test.go:56: 
        	Error Trace:	gitalyssh_test.go:56
        	Error:      	Should not be: "01EP8TTJK00000000000000000"
        	Test:       	TestGetCorrelationID/not_provided_in_context
        	Messages:   	it should return a new correlation_id each time as it is not injected into the context

This MR sets a randomness source to use by the ULID library.

Edited by Mikhail Mazurskiy

Merge request reports