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

Do not acquire lock for file.Sync() fsync call #404

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

1978629634
Copy link

@1978629634 1978629634 commented Apr 2, 2024

What this PR does / why we need it:

For file.Sync() (the fsync system call that flushes the kernel buffer to disk), there is no need to acquire a lock; let the kernel handle it.

Which issue(s) this PR fixes:

Fixes #403

Release note:

Do not acquire lock for file.Sync() fsync call

Copy link

linux-foundation-easycla bot commented Apr 2, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: 1978629634 / name: Chen Pu (79575d8)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Apr 2, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 2, 2024
@k8s-ci-robot
Copy link

Welcome @1978629634!

It looks like this is your first PR to kubernetes/klog 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/klog has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 2, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 2, 2024
@1978629634
Copy link
Author

1978629634 commented Apr 3, 2024

Hi @pohly @harshanarayana @mengjiao-liu , Could you please take a look at this pull request when you have a chance? I'd appreciate your review and feedback.

klog.go Outdated Show resolved Hide resolved
@dims
Copy link
Member

dims commented Apr 8, 2024

xref: golang#68

@1978629634
Copy link
Author

1978629634 commented Apr 8, 2024

xref: golang#68

Could you please review it again?

@yuzhiquan
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 9, 2024
@1978629634 1978629634 requested a review from dims April 9, 2024 15:05
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2024
@1978629634
Copy link
Author

xref: golang#68

Could you please review it again?

The changes to the glog have a potential issue. Besides the FlushDaemon, there is also an exit() call that invokes flushAll. If we release the lock and call file.Sync() in the exit code, the program may continue to write logs, which could lead to the program running longer than expected.
In the exit(), we should acquire the lock and call file.Sync() to ensure a clean shutdown.
cc @dims

@dims
Copy link
Member

dims commented Apr 11, 2024

/assign @pohly

@1978629634
Copy link
Author

@pohly I'd appreciate it if you could take a look at this pull request and offer any suggestions you may have. Your feedback would be invaluable. Thank you so much!

@pohly
Copy link

pohly commented May 2, 2024

I have it on my TODO list, but it may take a while before I get to it.

Copy link
Member

@logicalhan logicalhan left a comment

Choose a reason for hiding this comment

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

/triage accepted
/assign @pohly

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 2, 2024
@logicalhan
Copy link
Member

/assign @shiva1333

@k8s-ci-robot
Copy link

@logicalhan: GitHub didn't allow me to assign the following users: shiva1333.

Note that only kubernetes members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @shiva1333

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

klog.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 11, 2024
Copy link

@pohly pohly left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 11, 2024
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 1978629634, pohly, yuzhiquan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 11, 2024
@k8s-ci-robot k8s-ci-robot merged commit 2ee202a into kubernetes:main Jun 11, 2024
2 checks passed
renovate bot referenced this pull request in anza-labs/lke-operator Jun 15, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [k8s.io/klog/v2](https://togithub.com/kubernetes/klog) | `v2.120.1` ->
`v2.130.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/k8s.io%2fklog%2fv2/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/k8s.io%2fklog%2fv2/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/k8s.io%2fklog%2fv2/v2.120.1/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/k8s.io%2fklog%2fv2/v2.120.1/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>kubernetes/klog (k8s.io/klog/v2)</summary>

###
[`v2.130.0`](https://togithub.com/kubernetes/klog/releases/tag/v2.130.0):
Prepare klog release for Kubernetes v1.31 (Take 1)

[Compare
Source](https://togithub.com/kubernetes/klog/compare/v2.120.1...v2.130.0)

#### What's Changed

- chore(\*): fix spelling of Intel Corporation by
[@&#8203;jsoref](https://togithub.com/jsoref) in
[https://github.com/kubernetes/klog/pull/399](https://togithub.com/kubernetes/klog/pull/399)
- build: fix some linter warnings by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/402](https://togithub.com/kubernetes/klog/pull/402)
- examples: fix linter warning by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/406](https://togithub.com/kubernetes/klog/pull/406)
- Do not acquire lock for file.Sync() fsync call by
[@&#8203;1978629634](https://togithub.com/1978629634) in
[https://github.com/kubernetes/klog/pull/404](https://togithub.com/kubernetes/klog/pull/404)
- ktesting: tone down warning about leaked test goroutine by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/401](https://togithub.com/kubernetes/klog/pull/401)

#### New Contributors

- [@&#8203;jsoref](https://togithub.com/jsoref) made their first
contribution in
[https://github.com/kubernetes/klog/pull/399](https://togithub.com/kubernetes/klog/pull/399)
- [@&#8203;1978629634](https://togithub.com/1978629634) made their first
contribution in
[https://github.com/kubernetes/klog/pull/404](https://togithub.com/kubernetes/klog/pull/404)

**Full Changelog**:
kubernetes/klog@v2.120.1...v2.130.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/anza-labs/lke-operator).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjM5My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhcmVhL2RlcGVuZGVuY3kiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
MrAlias referenced this pull request in open-telemetry/opentelemetry-go-contrib Jun 17, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [k8s.io/klog/v2](https://togithub.com/kubernetes/klog) | `v2.120.1` ->
`v2.130.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/k8s.io%2fklog%2fv2/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/k8s.io%2fklog%2fv2/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/k8s.io%2fklog%2fv2/v2.120.1/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/k8s.io%2fklog%2fv2/v2.120.1/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>kubernetes/klog (k8s.io/klog/v2)</summary>

###
[`v2.130.0`](https://togithub.com/kubernetes/klog/releases/tag/v2.130.0):
Prepare klog release for Kubernetes v1.31 (Take 1)

[Compare
Source](https://togithub.com/kubernetes/klog/compare/v2.120.1...v2.130.0)

#### What's Changed

- chore(\*): fix spelling of Intel Corporation by
[@&#8203;jsoref](https://togithub.com/jsoref) in
[https://github.com/kubernetes/klog/pull/399](https://togithub.com/kubernetes/klog/pull/399)
- build: fix some linter warnings by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/402](https://togithub.com/kubernetes/klog/pull/402)
- examples: fix linter warning by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/406](https://togithub.com/kubernetes/klog/pull/406)
- Do not acquire lock for file.Sync() fsync call by
[@&#8203;1978629634](https://togithub.com/1978629634) in
[https://github.com/kubernetes/klog/pull/404](https://togithub.com/kubernetes/klog/pull/404)
- ktesting: tone down warning about leaked test goroutine by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/401](https://togithub.com/kubernetes/klog/pull/401)

#### New Contributors

- [@&#8203;jsoref](https://togithub.com/jsoref) made their first
contribution in
[https://github.com/kubernetes/klog/pull/399](https://togithub.com/kubernetes/klog/pull/399)
- [@&#8203;1978629634](https://togithub.com/1978629634) made their first
contribution in
[https://github.com/kubernetes/klog/pull/404](https://togithub.com/kubernetes/klog/pull/404)

**Full Changelog**:
kubernetes/klog@v2.120.1...v2.130.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/open-telemetry/opentelemetry-go-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQxMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJTa2lwIENoYW5nZWxvZyIsImRlcGVuZGVuY2llcyJdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
// Flush from fatal down, in case there's trouble flushing.
for _, file := range files {
if file != nil {
_ = file.Sync() // ignore error
Copy link

Choose a reason for hiding this comment

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

As noted in #403 (comment), syncBuffer is not thread-safe and here we call syncBuffer.Sync.

Will follow-up in #407.

codeboten referenced this pull request in open-telemetry/opentelemetry-collector-contrib Jun 19, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [k8s.io/klog/v2](https://togithub.com/kubernetes/klog) | `v2.120.1` ->
`v2.130.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/k8s.io%2fklog%2fv2/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/k8s.io%2fklog%2fv2/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/k8s.io%2fklog%2fv2/v2.120.1/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/k8s.io%2fklog%2fv2/v2.120.1/v2.130.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>kubernetes/klog (k8s.io/klog/v2)</summary>

###
[`v2.130.0`](https://togithub.com/kubernetes/klog/releases/tag/v2.130.0):
Prepare klog release for Kubernetes v1.31 (Take 1)

[Compare
Source](https://togithub.com/kubernetes/klog/compare/v2.120.1...v2.130.0)

#### What's Changed

- chore(\*): fix spelling of Intel Corporation by
[@&#8203;jsoref](https://togithub.com/jsoref) in
[https://github.com/kubernetes/klog/pull/399](https://togithub.com/kubernetes/klog/pull/399)
- build: fix some linter warnings by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/402](https://togithub.com/kubernetes/klog/pull/402)
- examples: fix linter warning by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/406](https://togithub.com/kubernetes/klog/pull/406)
- Do not acquire lock for file.Sync() fsync call by
[@&#8203;1978629634](https://togithub.com/1978629634) in
[https://github.com/kubernetes/klog/pull/404](https://togithub.com/kubernetes/klog/pull/404)
- ktesting: tone down warning about leaked test goroutine by
[@&#8203;pohly](https://togithub.com/pohly) in
[https://github.com/kubernetes/klog/pull/401](https://togithub.com/kubernetes/klog/pull/401)

#### New Contributors

- [@&#8203;jsoref](https://togithub.com/jsoref) made their first
contribution in
[https://github.com/kubernetes/klog/pull/399](https://togithub.com/kubernetes/klog/pull/399)
- [@&#8203;1978629634](https://togithub.com/1978629634) made their first
contribution in
[https://github.com/kubernetes/klog/pull/404](https://togithub.com/kubernetes/klog/pull/404)

**Full Changelog**:
kubernetes/klog@v2.120.1...v2.130.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any
time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTAuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQxMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZWJvdCJdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
6 participants