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

(batchprocessor): block requests until response is received #71

Merged
merged 12 commits into from
Nov 3, 2023

Conversation

moh-osman3
Copy link
Contributor

@moh-osman3 moh-osman3 commented Oct 26, 2023

Part 2 for #80

This PR adds the batchprocessor to otel-arrow with a couple enhancements:

  • block requests until the batch response is received
  • errors reported to producers; timeout will now report an error

The main files to review are batch_processor.go and batch_processor_test.go

jmacd pushed a commit that referenced this pull request Nov 3, 2023
Splitting up #71 into 2
PR's. This first PR is just simply forking the batchprocessor into this
repository before applying further changes on top.

Part of #80.
@moh-osman3 moh-osman3 force-pushed the mohosman/batchprocessor branch from 2347913 to bdbbabd Compare November 3, 2023 18:25
@moh-osman3 moh-osman3 changed the title (batchprocessor): add enhanced batchprocessor component (batchprocessor): block requests until response is received Nov 3, 2023
@moh-osman3 moh-osman3 marked this pull request as ready for review November 3, 2023 18:33
collector/processor/batchprocessor/batch_processor.go Outdated Show resolved Hide resolved
} else { // waiter gets a complete response.
numItemsBefore += b.pending[0].numItems
if trigger == triggerTimeout {
err = multierr.Append(err, errTimedOut)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this looks like we're making up an error, let's discuss. Is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh maybe I'm confused.. should the waiter be notified if their request times out? I thought the answer was yes, so that's why I'm letting the completeError indicate the timeout. Do you think timeout should simply be logged instead?


numItemsBefore := b.totalSent
numItemsAfter := b.totalSent + sent
// The current batch can contain items from several different producers. Ensure each producer gets a response back.
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: in a follow-on PR I'd like the export to happen in the background -- it's going to mean running through this loop before calling export, so we know the set of complete/pending responses that will be returned when the response comes back.

var (
// errTooManyBatchers is returned when the MetadataCardinalityLimit has been reached.
errTooManyBatchers = consumererror.NewPermanent(errors.New("too many batcher metadata-value combinations"))
errTimedOut = errors.New("processing items timed out")
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: It looks to me like a non-error condition below, where you used this variable. Maybe we can remove it, let's discuss.

respCh := make(chan error, 1)
// TODO: add a semaphore to only write to channel if sizeof(data) keeps
// us below some configured inflight byte limit.
sb.batcher.newItem <- dataItem{
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: not for now, but to consider: if the other side of this channel is being slow, this will block until after the context times out. This could instead be more defensive, like

   select {
    case sb.batcher.newItem <- dataItem{...}:
       // ok
     case <-ctx.Done():
       return ctx.Err()
     }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out! I went ahead and added the select statement you suggested

Copy link
Contributor

@jmacd jmacd left a comment

Choose a reason for hiding this comment

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

Thanks! Nice work. The test changes look tedious, thanks for doing this.

@jmacd jmacd merged commit c384fcf into open-telemetry:main Nov 3, 2023
1 check passed
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.

2 participants