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

feat(client): add call timeout to log stream appender #471

Closed
wants to merge 1 commit into from

Conversation

ijsong
Copy link
Member

@ijsong ijsong commented Jun 9, 2023

What this PR does

This PR adds a call timeout to the log stream appender. It helps the log stream appender not to be blocked.
LogStreamAppender can be blocked at the following points:

  • (a) Waiting for the pipeline to have room
  • (b) Flow-controlled when calling RPC
  • (c) Stucked server
  • (d) Slow callback
+------+            +-------------------------+            +--------+
|      |            |    LogStreamAppender    |            |        |
|      |            |                         |            |        |
|      |            |  (a)----------------(b) |            |        |
|      +--AppendBatch--->| pipeline queue |--gRPC request->|        |
| User |            |    +----------------+   |            |        |
| code |            |                         |            | Varlog |
|      |            |    +----------------+   |            |        |
|      |            |    |    callback    |   |            |        |
|      |<--Callback-+----|   processing   |<-gRPC response-+        |
|      |            |  (c)   goroutine    (d) |            |        |
|      |            |    +----------------+   |            |        |
+------+            +-------------------------+            +--------+

When a user configures call timeout by using pkg/varlog.WithCallTimeout, the pkg/varlog.(LogStreamAppender).AppendBatch or its callback function can return ErrCallTimeout when above situations.

This PR adds a call timeout to the log stream appender. It helps the log stream appender not to be
blocked. LogStreamAppender can be blocked at the following points:

- (a) Waiting for the pipeline to have room
- (b) Flow-controlled when calling RPC
- (c) Stucked server
- (d) Slow callback

```
+------+            +-------------------------+            +--------+
|      |            |    LogStreamAppender    |            |        |
|      |            |                         |            |        |
|      |            |  (a)----------------(b) |            |        |
|      +--AppendBatch--->| pipeline queue |--gRPC request->|        |
| User |            |    +----------------+   |            |        |
| code |            |                         |            | Varlog |
|      |            |    +----------------+   |            |        |
|      |            |    |    callback    |   |            |        |
|      |<--Callback-+----|   processing   |<-gRPC response-+        |
|      |            |  (c)   goroutine    (d) |            |        |
|      |            |    +----------------+   |            |        |
+------+            +-------------------------+            +--------+
```

When a user configures call timeout by using `pkg/varlog.WithCallTimeout`, the
`pkg/varlog.(LogStreamAppender).AppendBatch` or its callback function can return ErrCallTimeout when
above situations.
@ijsong
Copy link
Member Author

ijsong commented Jun 9, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@ijsong ijsong self-assigned this Jun 9, 2023
@codecov-commenter
Copy link

Codecov Report

Patch coverage has no change and project coverage change: -0.24 ⚠️

Comparison is base (4695075) 62.63% compared to head (41b5d2b) 62.40%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #471      +/-   ##
==========================================
- Coverage   62.63%   62.40%   -0.24%     
==========================================
  Files         133      133              
  Lines       18336    18386      +50     
==========================================
- Hits        11485    11474      -11     
- Misses       6276     6336      +60     
- Partials      575      576       +1     
Impacted Files Coverage Δ
pkg/varlog/config.go 47.76% <0.00%> (-3.04%) ⬇️
pkg/varlog/log_stream_appender.go 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ijsong ijsong marked this pull request as ready for review June 9, 2023 11:00
@ijsong ijsong requested a review from hungryjang as a code owner June 9, 2023 11:00
@ijsong ijsong marked this pull request as draft June 12, 2023 00:15
@ijsong ijsong marked this pull request as draft June 12, 2023 00:15
@ijsong ijsong closed this Jun 12, 2023
@ijsong ijsong deleted the log_stream_appender_call_timeout branch June 12, 2023 03:51
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.

None yet

2 participants