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

Fix Child Process not working for BGREWRITEAOF on MacOS + Logging Improvements #704

Merged

Conversation

KaviiSuri
Copy link
Contributor

@KaviiSuri KaviiSuri commented Sep 23, 2024

This PR fixes BGREWRITEAOF failing completely, Specifically for MacOS for now .

The root cause is that macos doesn't set pid to 0 for child process

The solution is to record get original pid of main process and do isChild := syscall.Getppid() == originalPID. The pid == 0 check is unreliable and breaks on maocs m2 in my testing.

This PR also adds logging features and a bit of refactoring to reuse code and allow for logger.With(...attrs) to be logged correctly

@KaviiSuri KaviiSuri changed the title Fix Child Process not working for BGREWRITEAOF Fix Child Process not working for BGREWRITEAOF on MacOS + Logging Improvements Sep 23, 2024
@KaviiSuri
Copy link
Contributor Author

@lucifercr07 @vinitparekh17 could you review the changes here?

@JyotinderSingh
Copy link
Collaborator

Please rebase on the latest master

@KaviiSuri KaviiSuri force-pushed the kavii/fix-multiple-aof-rewrite branch from f12a05c to 9494d59 Compare September 25, 2024 07:10
@KaviiSuri
Copy link
Contributor Author

@JyotinderSingh , done

@KaviiSuri
Copy link
Contributor Author

@JyotinderSingh are there any blockers to merge this? Any effort required from my end?

@JyotinderSingh
Copy link
Collaborator

@JyotinderSingh are there any blockers to merge this? Any effort required from my end?

Reviewing this

@KaviiSuri KaviiSuri force-pushed the kavii/fix-multiple-aof-rewrite branch from 9494d59 to ed5a0f1 Compare September 26, 2024 12:20
Copy link
Contributor

@lucifercr07 lucifercr07 left a comment

Choose a reason for hiding this comment

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

Thanks @KaviiSuri for fixing this, validated locally works fine in single threaded mode.
Can you please point to doc where you found this Macos M2 behaviour, wasn't able to find any concrete documentation around this behaviour.

@KaviiSuri
Copy link
Contributor Author

KaviiSuri commented Sep 26, 2024

@lucifercr07 i couldn't find the exact docs, but i did find a lot of people facing the same issue. Although, the solution implemented is quite generic, we just compare pid with previously recorded one, so it should be safe regadless if the fork return value behaviour

also, apparently, both implementations of golang and python had to deal with such peculiarities on MacOS

@JyotinderSingh JyotinderSingh merged commit f512096 into DiceDB:master Sep 26, 2024
2 checks passed
@JyotinderSingh
Copy link
Collaborator

JyotinderSingh commented Sep 26, 2024

Thank you for these fixes.

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.

3 participants