Repository navigation
Fix clash between progress meter and credential helper - #1886
Conversation
ttaylorr
left a comment
There was a problem hiding this comment.
Looking great -- I'm psyched that this was easier than my estimation.
I posted one nit (which you can feel free to ignore), and one clarifying question to make sure that I'm on the same page with how this works when Batch() early-returns.
Other than that, I think this is ready to merge 👍 .
| } | ||
|
|
||
| func (p *ProgressMeter) Pause() { | ||
| if atomic.SwapInt32(&p.started, 0) == 1 { |
There was a problem hiding this comment.
Nit: Using atomic.CompareAndSwapInt32(&p.started, 1, 0) accomplishes the same behavior.
There was a problem hiding this comment.
Ah good call. This was copy pasta from Start(), but I'll tweak both.
| } | ||
|
|
||
| q.useAdapter(bRes.TransferAdapterName) | ||
| q.startProgress.Do(q.meter.Start) |
There was a problem hiding this comment.
Before we resume the progress meter, we have two opportunities to bail out early: on L302 and L306. I think both of those are fine, since we'd exit this function early, and the progress meter would get resumed the next time a new batch was enqueued. There'd be no issues with calling Pause() twice, since there's a CompareAndSwap<T> operation guarding the channel send into p.finished.
@technoweenie would you mind double checking my thinking on this?
There was a problem hiding this comment.
Seems legit. I went ahead and added some tests in the progress package to assert that Start() and Pause() can be called multiple times.
ttaylorr
left a comment
There was a problem hiding this comment.
Thanks for addressing. Looks like there are some test failures, but I'm throwing up my approval to unblock your merge.
|
Well, since I made |
4a79bce to
7f4334c
Compare
|
Welp, those changes did not make things happier. I backed out of them in this PR. |
👍 |
This is an attempt to fix #847. It pauses the progress meter before making the batch api request, and then starts it when it passing the batch api response to the transfer adapters. This works because:
(progress.Meter) Start(),Finish(), andPause()internally use channels andatomic/sync. No need for thatsync.Onceintq.TransferQueue.tq.TransferQueueonly transfers items from a single batch concurrently. The sequence (Batch API -> n transfer adapter workers) runs sequentially, so that the next batch (if needed) can process the retries from the previous batch.Unfortunately, there isn't really a way to test this, since it requires interactive input. Here's an example of this PR working (with a tiny hack to change the batch size to 2):
Here's the same, without pausing: