Skip to content

changefeedccl: retry webhook sink requests upon HTTP error#67686

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
spiffyy99:changefeed-http-sink-retries
Jul 20, 2021
Merged

changefeedccl: retry webhook sink requests upon HTTP error#67686
craig[bot] merged 1 commit intocockroachdb:masterfrom
spiffyy99:changefeed-http-sink-retries

Conversation

@spiffyy99
Copy link
Copy Markdown
Contributor

Before, webhook sink requests simply resulted in retryable changefeed
errors upon failure. This change adds default retry behavior for HTTP
requests, preventing the need for changefeeds to shut down and restart
every time.

Resolves #67312

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable


func defaultRetryConfig() retryConfig {
return retryConfig{
backoff: 500 * time.Millisecond,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

open to discussing this default config further (similar to kafka except backoff 250 -> 500)

@spiffyy99 spiffyy99 force-pushed the changefeed-http-sink-retries branch from f3f2611 to 8e768d5 Compare July 19, 2021 14:11
@spiffyy99 spiffyy99 force-pushed the changefeed-http-sink-retries branch from 8e768d5 to 292d84e Compare July 19, 2021 17:28
@spiffyy99 spiffyy99 marked this pull request as ready for review July 19, 2021 17:29
@spiffyy99 spiffyy99 force-pushed the changefeed-http-sink-retries branch from 292d84e to 0f051a3 Compare July 19, 2021 20:19
Copy link
Copy Markdown
Contributor

@miretskiy miretskiy left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r5, 2 of 6 files at r6.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @spiffyyeng)


pkg/ccl/changefeedccl/sink_webhook.go, line 213 at r6 (raw file):

}

func defaultRetryConfig() retry.Options {

add TODO to make this configurable ?


pkg/ccl/changefeedccl/sink_webhook.go, line 220 at r6 (raw file):

	}
	// max backoff should be initial * 2 ^ maxRetries
	opts.MaxBackoff = opts.InitialBackoff * time.Duration(int(math.Pow(2.0, float64(opts.MaxRetries))))

do you need to set this? Do we need such high precision?


pkg/ccl/changefeedccl/sink_webhook.go, line 266 at r6 (raw file):

func (s *webhookSink) sendMessageWithRetries(ctx context.Context, reqBody []byte) error {
	requestFunc := func() error {
		err := s.sendMessage(ctx, reqBody)

just return s.sendMessge(ctx, reqBody)?


pkg/ccl/changefeedccl/sink_webhook_test.go, line 386 at r6 (raw file):

Quoted 4 lines of code…
		err = sinkSrc.Close()
		if err != nil {
			t.Fatal(err)
		}

You can just do require.NoError(t, sinkSrc.Close())


pkg/ccl/changefeedccl/sink_webhook_test.go, line 405 at r6 (raw file):

Quoted 4 lines of code…
		sinkDestHost, err := url.Parse(sinkDest.URL())
		if err != nil {
			t.Fatal(err)
		}

require.NoError?

Before, webhook sink requests simply resulted in retryable changefeed
errors upon failure. This change adds default retry behavior for HTTP
requests, preventing the need for changefeeds to shut down and restart
every time.

Resolves cockroachdb#67312

Release note: None
Copy link
Copy Markdown
Contributor Author

@spiffyy99 spiffyy99 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @miretskiy and @spiffyyeng)


pkg/ccl/changefeedccl/sink_webhook.go, line 220 at r6 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

do you need to set this? Do we need such high precision?

reason we're setting this here is because the default MaxBackoff is 2 seconds. Thinking ahead to when we make this configurable, if users set a high initial backoff, they will expect to see max backoff higher than 2 seconds (depending on what they set).

@spiffyy99 spiffyy99 force-pushed the changefeed-http-sink-retries branch from 0f051a3 to 0e5039e Compare July 19, 2021 21:51
@spiffyy99
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jul 20, 2021

Build succeeded:

@craig craig bot merged commit f89b2a6 into cockroachdb:master Jul 20, 2021
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.

changefeedccl: Add HTTP request retry functionality for webhook sink

3 participants