Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binlog filepath uniquification option #10051

Merged
merged 4 commits into from
Apr 23, 2024

Conversation

JanKrivanek
Copy link
Member

@JanKrivanek JanKrivanek commented Apr 22, 2024

Fixes #8817

Context

There are cases where explicit unique binlog paths cannot be specified and the implicit overwriting behavior is complicating the invectigations (e.g. the implicit separate restore step invoked by sdk - as per #9614).

For those cases let's introduce a simplistic uniquification opt-in mechanism: When specifying a '{}' substring withing the binlog path parameter - this is going to be expanded into a timestamp plus random stamp.

Behavior:

  • Only '{}' is recognized and expanded. If the brackets have any content - it's intentionally left untouched (this can be added in future iteration if there is any need)
  • If '{}' is present, then the '.binlog' extension is ensured (whether specified in original name or not)
  • Each '{}' in the binlog path argument is replaced with timestamp and random string stamp
  • Custom expander can be injected - this is mainly for unit tests, but can be used if anyone wants different uniquification
  • Intentionally no build-time information (entrypoint project, target, etc) is added - KISS principle. All needed information can be located within the binlog. We can iterate on this if requested and needed.

Samples:

  • -bl:{} --> 20240423-102016--16636--anxG+w.binlog
  • -bl:LogFile=MyBinlog-{}.binlog --> MyBinlog-20240423-102016--16636--anxG+w.binlog
  • -bl:{something}.binlog --> {something}.binlog

Changes Made

The parameters parsing is extended, so that it can recognize and expand '{}'

Testing

Existing tests. + added tailored tests for pre-existing and new naming interpretation

Notes

This can technically be breaking - but the likelyhood is quite low (I tried to search GH and ADO for usage of binlog, where explicit path would be specified and contained '{}' - and found none). S I'd prefer clean experience rather then adding additional commandline arguments. It is still behind the change wave - if anything goes wrong.

FYI @KirillOsenkov

@JanKrivanek JanKrivanek requested a review from a team as a code owner April 22, 2024 11:24
Copy link
Contributor

@f-alizada f-alizada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delaying with the PR and proper fix for the opt-in mechanism, the changes looks good.
If the completely opt-in mechanism will be required please let me know, I have some draft changes that could be used as well :)

src/Build/Logging/BinaryLogger/BinaryLogger.cs Outdated Show resolved Hide resolved
src/Build.UnitTests/BinaryLogger_Tests.cs Outdated Show resolved Hide resolved
@JanKrivanek
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@KirillOsenkov
Copy link
Member

I like the design!

I feel pretty strongly that we should remove the interface and just use Func<string> to obtain the random string. If it's null, fall back to the default (current) implementation.

Nothing in this PR should be adding any new public API.

Also would be nice if the process ID of the node was featured in the random string.

Also let's add a dash between date and time.

@JanKrivanek
Copy link
Member Author

I like the design!

I feel pretty strongly that we should remove the interface and just use Func<string> to obtain the random string. If it's null, fall back to the default (current) implementation.

Nothing in this PR should be adding any new public API.

Also would be nice if the process ID of the node was featured in the random string.

Also let's add a dash between date and time.

Update format based on suggestions - the sample result is in the updated PR description

@JanKrivanek JanKrivanek merged commit d542f3a into dotnet:main Apr 23, 2024
10 checks passed
@JanKrivanek JanKrivanek deleted the proto/binlog-unique-names branch April 23, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Opt-in mechanism for unique default names of binlogs
5 participants