Skip to content

Commit

Permalink
[fix][fn]Reset idle timer correctly (apache#20450)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy Walker <andy@andy.dev>

Fix apache#20449

<!-- or this PR is one task of an issue -->

Master Issue: apache#20449

### Verifying this change

- [ ] Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

### Does this pull request potentially affect one of the following parts:

<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->

*If the box was checked, please highlight the changes*

- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment

### Documentation

<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->

- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [X] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->

### Matching PR in forked repository

PR in forked repository: flowchartsman#5
  • Loading branch information
flowchartsman authored Jun 1, 2023
1 parent f86e36f commit e05b890
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pulsar-function-go/pf/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func (gi *goInstance) startFunction(function function) error {
defer metricsServicer.close()
CLOSE:
for {
idleTimer.Reset(idleDuration)
select {
case cm := <-channel:
msgInput := cm.Message
Expand Down Expand Up @@ -181,6 +180,11 @@ CLOSE:
close(channel)
break CLOSE
}
// reset the idle timer and drain if appropriate before the next loop
if !idleTimer.Stop() {
<-idleTimer.C
}
idleTimer.Reset(idleDuration)
}

gi.closeLogTopic()
Expand Down

0 comments on commit e05b890

Please sign in to comment.