Skip to content

Retry file writes on EINTR errors#173

Merged
estesp merged 1 commit into
containerd:masterfrom
adunham-stripe:adunham/writefile-eintr
Jul 7, 2020
Merged

Retry file writes on EINTR errors#173
estesp merged 1 commit into
containerd:masterfrom
adunham-stripe:adunham/writefile-eintr

Conversation

@adunham-stripe
Copy link
Copy Markdown
Contributor

@adunham-stripe adunham-stripe commented Jul 7, 2020

Go 1.14 introduces asynchronous preemption, which results in
applications that invoke slow syscalls (e.g. writing to a cgroup file)
getting EINTR errors. The Go runtime will fix this in version 1.15
onwards:
golang/go#38033

But this fix won't be backported:
golang/go#39026 (comment)

As such, introduce a 'writeFile' helper function that retries when the
error is an EINTR error.

This is also the approach taken in runc: opencontainers/runc#2258

Signed-off-by: Andrew Dunham adunham@stripe.com

@adunham-stripe adunham-stripe force-pushed the adunham/writefile-eintr branch 2 times, most recently from f2c27b8 to 8e734c8 Compare July 7, 2020 03:01
Go 1.14 introduces asynchronous preemption, which results in
applications that invoke slow syscalls (e.g. writing to a cgroup file)
getting EINTR errors. The Go runtime will fix this in version 1.15
onwards:
    golang/go#38033

But this fix won't be backported:
    golang/go#39026 (comment)

As such, introduce a 'writeFile' helper function that retries when the
error is an EINTR error.

Signed-off-by: Andrew Dunham <adunham@stripe.com>
@adunham-stripe adunham-stripe force-pushed the adunham/writefile-eintr branch from 8e734c8 to 44e3a02 Compare July 7, 2020 03:35
Copy link
Copy Markdown
Contributor

@Zyqsempai Zyqsempai left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@estesp estesp merged commit 4ef69bc into containerd:master Jul 7, 2020
@estesp estesp mentioned this pull request Jul 7, 2020
@adunham-stripe adunham-stripe deleted the adunham/writefile-eintr branch July 7, 2020 16:16
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.

4 participants