gunli opened a new pull request, #1145:
URL: https://github.com/apache/pulsar-client-go/pull/1145

   <!--
   ### Contribution Checklist
     
     - Name the pull request in the form "[Issue XYZ][component] Title of the 
pull request", where *XYZ* should be replaced by the actual issue number.
       Skip *Issue XYZ* if there is no associated github issue for this pull 
request.
       Skip *component* if you are unsure about which is the best component. 
E.g. `[docs] Fix typo in produce method`.
   
     - Fill out the template below to describe the changes contributed by the 
pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from 
multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and 
this checklist, leaving only the filled out template below.
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   *(If this PR fixes a github issue, please add `Fixes #<xyz>`.)*
   
   Fixes #<xyz>
   
   *(or if this PR is one task of a github issue, please add `Master Issue: 
#<xyz>` to link to the master issue.)*
   
   Master Issue: #<xyz>
   
   ### Motivation
   
   When I run client in K8s pods(keepAliveInterval=5s), connections are closed 
occasionally, I can't find the root cause, when I look into the code, I found 
`c.lastDataReceivedTime` is not updated in `doHandshake()`, if we have no data 
to send the first check of `c.lastDataReceivedTime` probably tell the 
connection is stale and close it, I think it is better to update 
`c.lastDataReceivedTime` when doHandshake() succeed.
   
   ```go
   newConnection()// the first set here
   doHandshake()// not set here
   internalReceivedCommand()// the second set here
   runPingCheck()// the first check here
   ```
   
   
![conn-close](https://github.com/apache/pulsar-client-go/assets/10734543/c1f7a17d-981d-45b4-b496-d5a5de72fbe7)
   
   ### Modifications
   
   ```go
   func (c *connection) doHandshake() bool {    
        c.log.Info("Connection is ready")
        c.setLastDataReceived(time.Now()) // update last data received time here
        c.changeState(connectionReady)
        return true
   }
   ```
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe 
tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads 
(10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API: (yes / no)
     - The schema: (yes / no / don't know)
     - The default values of configurations: (yes / no)
     - The wire protocol: (yes / no)
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable / docs / GoDocs / 
not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup 
issue for adding the documentation
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to