Skip to content
New issue

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

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

Already on GitHub? # to your account

Refactor cbdb_log to use vfprintf #506

Merged
merged 1 commit into from
Jul 29, 2024
Merged

Conversation

ruhuang2001
Copy link
Contributor

  • Replaced fprintf with vfprintf in cbdb_log to handle variable arguments more efficiently

fix #89


Change logs

Describe your change clearly, including what problem is being solved or what feature is being added.

If it has some breaking backward or forward compatibility, please clary.

Why are the changes needed?

Describe why the changes are necessary.

Does this PR introduce any user-facing change?

If yes, please clarify the previous behavior and the change this PR proposes.

How was this patch tested?

Please detail how the changes were tested, including manual tests and any relevant unit or integration tests.

Contributor's Checklist

Here are some reminders and checklists before/when submitting your pull request, please check them:

  • Make sure your Pull Request has a clear title and commit message. You can take git-commit template as a reference.
  • Sign the Contributor License Agreement as prompted for your first-time contribution(One-time setup).
  • Learn the coding contribution guide, including our code conventions, workflow and more.
  • List your communication in the GitHub Issues or Discussions (if has or needed).
  • Document changes.
  • Add tests for the change
  • Pass make installcheck
  • Pass make -C src/test installcheck-cbdb-parallel
  • Feel free to request cloudberrydb/dev team for review and approval when your PR is ready🥳

@CLAassistant
Copy link

CLAassistant commented Jul 8, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hiiii, @ruhuang2001 welcome!🎊 Thanks for taking the effort to make our project better! 🙌 Keep making such awesome contributions!

@tuhaihe
Copy link
Member

tuhaihe commented Jul 9, 2024

@ruhuang2001 thanks for your contribution!

@wenchaozhang-123
Copy link
Contributor

Please add test cases.

@ruhuang2001
Copy link
Contributor Author

Please add test cases.

OK, I understand, but I am not very familiar with the whole system. What are the requirements or standards for the test cases, or can you give me some suggestions? Thanks a lot!

@wenchaozhang-123
Copy link
Contributor

Please add test cases.

OK, I understand, but I am not very familiar with the whole system. What are the requirements or standards for the test cases, or can you give me some suggestions? Thanks a lot!

Always we should add test in regress/isolation/isolation2/tap test etc when fix code, but this change is related with log output which is not convenient to add test case. Maybe it's ok to merge this without test case while it's better to consider other ways to add some test? What's more, we should remove unnecessary code diff.

@avamingli
Copy link
Contributor

Hi, thanks for your contribution. The codes overall looks good to me, and you could do better.
The most rewarding part of this issue, use vfprintf instead of vsnprintf is to avoid unnecessary buffer: char buffer[1000];
Your changes are good, but there is another char buffer[1000] in same function, line: 103. Could you fix them all?
Another is the commit message, I see there is a star * in your commit message which should be removed, we are follow PG style.
About the extra line at the end of file, I think your change is ok.
We should always put an empty line for files, there is no need to fix all files, but it's ok to add empty line by the way.

@tuhaihe
Copy link
Member

tuhaihe commented Jul 10, 2024

For writing a good commit message, welcome to take this template for reference.

For more tips on Git/GitHub and contribution guide, see here: https://cloudberrydb.org/contribute#find-a-way-to-contribute.

Hope can help you!

@ruhuang2001
Copy link
Contributor Author

Thanks for suggestions and review!

What's more, we should remove unnecessary code diff.

I found that it might be a Windows newline character issue. When I edited in the web editor, autocrlf was enabled by default. I fix in the latest commit.

there is another char buffer[1000] in same function, line: 103. Could you fix them all?

In the latest changes, I tried to use fprintf to avoid using a buffer.

I see there is a star * in your commit message which should be removed

When I was addressing the * issue in the previous commit, I accidentally used force push, which seems to have corrupted the commit. Should I create a new branch to submit the changes ? I am so sorry 😢

@avamingli
Copy link
Contributor

Should I create a new branch to submit the changes ?

You could use git rebase to arrange your codes to the top, refer to git manual.
And we don't use Merge commit in CBDB, please use git rebase instead to catch up with main branch.
All changes should be in one commit of yourself.

@ruhuang2001 ruhuang2001 force-pushed the main branch 2 times, most recently from cde3a76 to e1de740 Compare July 10, 2024 09:24
@ruhuang2001
Copy link
Contributor Author

ruhuang2001 commented Jul 10, 2024

Ok, now all my own commits are merged into one committ.

@fanfuxiaoran
Copy link
Contributor

@avamingli 'src/fe_utils/log.c' this file is not found in postgres, is it added by cbdb?
And cbdb_log is only used by fts. I can not understand why it is built as frontend mode and exposed.

@avamingli
Copy link
Contributor

avamingli commented Jul 12, 2024

src/fe_utils/log.c' this file is not found in postgres, is it added by cbdb?

Yes.

And cbdb_log is only used by fts. I can not understand why it is built as frontend mode and exposed.

I'm not sure. Hi, @jiaqizho do you have any context about this?

Using vfprintf to avoid unnecessary buffer
@jiaqizho
Copy link
Contributor

jiaqizho commented Jul 23, 2024

src/fe_utils/log.c' this file is not found in postgres, is it added by cbdb?

Yes.

And cbdb_log is only used by fts. I can not understand why it is built as frontend mode and exposed.

I'm not sure. Hi, @jiaqizho do you have any context about this?

yes, it added by yifan, used to provider a log util for the fe process.

The reason why it is built as frontend mode and exposed is that we don't want use the same log path with the elog, i guess.

@my-ship-it my-ship-it merged commit a5d00de into apache:main Jul 29, 2024
11 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refine the logic of Fts log on CBDB
8 participants