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

Change Composite Writer to Sequential Writer #930

Closed
wants to merge 3 commits into from

Conversation

davit-y
Copy link
Contributor

@davit-y davit-y commented Jul 12, 2018

Which problem is this PR solving?

Short description of the changes

  • As part of the necessary changes to add the Ingester, the Composite Writer will fail at the first error when writing spans as opposed to continuing with the next storage type.
  • Consider the case where the second storage type is not idempotent, and the first storage type fails to process a span. With a Composite Writer, on every retry, the second storage will have redundant spans written to it. With a Sequential Writer, the second storage type won't be attempted until the write to the first storage type succeeds.

Davit Yeghshatyan added 3 commits July 10, 2018 15:01
Signed-off-by: Davit Yeghshatyan <[email protected]>
Signed-off-by: Davit Yeghshatyan <[email protected]>
@codecov
Copy link

codecov bot commented Jul 12, 2018

Codecov Report

Merging #930 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #930   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         126    126           
  Lines        6074   6073    -1     
=====================================
- Hits         6074   6073    -1
Impacted Files Coverage Δ
storage/spanstore/composite.go 100% <100%> (ø) ⬆️
plugin/storage/factory.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0dc40e...1dc5dc8. Read the comment docs.

@davit-y davit-y mentioned this pull request Jul 12, 2018
9 tasks
)

// CompositeWriter is a span Writer that tries to save spans into several underlying span Writers
type CompositeWriter struct {
// SequentialWriter is a span Writer that tries to save spans into several underlying span Writers
Copy link
Member

Choose a reason for hiding this comment

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

Expression error semantics here. End sentences with periods.

@@ -40,16 +39,16 @@ func (n *noopWriteSpanStore) WriteSpan(span *model.Span) error {
}

func TestCompositeWriteSpanStoreSuccess(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Make test names match the type name

c := NewCompositeWriter(&errProneWriteSpanStore{}, &errProneWriteSpanStore{})
assert.EqualError(t, c.WriteSpan(nil), fmt.Sprintf("[%s, %s]", errIWillAlwaysFail, errIWillAlwaysFail))
c := NewSequentialWriter(&errProneWriteSpanStore{}, &errProneWriteSpanStore{})
assert.EqualError(t, c.WriteSpan(nil), errIWillAlwaysFail.Error())
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you can correctly test this way because you can't tell the difference between which writer returns the error. I suggest to change noop writer to take an optional err parameter that it always returns, and do a data driven test where you pass different permutations of 3 noop writers with and without errors and check for the right error in the end.

@jpkrohling
Copy link
Contributor

Consider the case where the second storage type is not idempotent, and the first storage type fails to process a span. With a Composite Writer, on every retry, the second storage will have redundant spans written to it. With a Sequential Writer, the second storage type won't be attempted until the write to the first storage type succeeds.

What about the second of three writers fail?

@yurishkuro
Copy link
Member

yurishkuro commented Jul 12, 2018

The behavioral change here is not properly reflected by the name Sequential, the old composite writer was also sequential. The real change is fail-fast on errors. You may want to add an options struct to the constructor with a Boolean field failFast. This way you'll preserve the old opportunistic behavior.

Regarding retries, I don't think it's in scope of this composition, it's up to individual writers.

@vprithvi
Copy link
Contributor

This way you'll preserve the old opportunistic behavior.

Do we require this opportunistic behavior?

I like the name SequentialWriter or even SequentialFailFastWriter better because it is more descriptive. While CompositeWriter is implemented sequentially, the name itself doesn't allude to that behavior (A writer with the same name may write parallely for e.g.)

@davit-y
Copy link
Contributor Author

davit-y commented Jul 19, 2018

Changing the CompositeWriter was found to be unnecessary to complete the Ingester. In addition, the use case of a SequentialWriter is not yet well defined

@davit-y davit-y closed this Jul 19, 2018
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.

4 participants