Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-3070

Investigate adding a RetryableError interface to mongo package

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Context

      There are various errors in the Go Driver that have Retryable() methods. These include

      • WriteCommandError
      • WriteConcernError
      • poolClearedError
      • retryableError

      Currently there exists an interface called RetryablePoolError in the driver package for which all of these errors implement. However, it doesn't quite fit the context of any of the errors except poolClearedError.

      It would be convenient for users to be able to check if an error is retryable at the mongo-package level. For example:

      rerr, ok := err.(mongo.RetryableError)
      
      if ok && rerr.Retryable() {
         // do something knowing the error is retryable
      }
      

      mongo.Retryable would look something like this:

      type RetryableError interface {
         Retryable() bool 
      }
      

      Definition of done

      We should answer the following questions before implementing:

      1. Is it driver-appropriate to provide a way for users to determine if an error is retryable? I.e. is this something we should give an opinion on?
      2. Is providing an interface the best solution. Could we instead check the retryablity internally and wrap the error in an error-implementing struct?

      Pitfalls

      It could be dangerous to add opinions on retryable errors in the stable API.

            Assignee:
            Unassigned Unassigned
            Reporter:
            preston.vasquez@mongodb.com Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: