awslogs: Fix a race in mockcwlogsclient#22985
Conversation
f0d8884 to
1544ac6
Compare
|
Is that race is real for a real client? Because I think it's pretty the same as copy and even slightly worse, because not preallocating anything :( |
|
@LK4D4 I'm not sure there's really a race in the driver as opposed to the test, but this does avoid a (potentially large) copy. To answer your question on #22971, Preallocation can be changed, but what I have now is fairly similar behavior to the truncation that was already occurring. |
|
If it's blocking then let's make mockClient blocking and avoid allocations at all :) |
|
@LK4D4 Making |
|
@samuelkarp could you post race detector output pls? |
|
samuelkarp@21a5189 shows the |
|
Ok, mockClient code is confusing, but as I understand issue we need to make copy of events inside |
|
@LK4D4 That seems to work too. I'll update this PR with that change. |
|
(Also, if Docker has picked a mock generation tool, I'd be happy to switch away from this confusing, hand-written mock.) |
Signed-off-by: Samuel Karp <skarp@amazon.com>
1544ac6 to
c1ad02c
Compare
|
@LK4D4 PTAL |
|
LGTM |
1 similar comment
|
LGTM |
- What I did
Fixed a race found in #22963 differently than #22971
- How I did it
Copy the
LogEventsslice inmockcwlogsclient.PutLogEventssince the tests may read through the slice asynchronously- How to verify it
TESTDIRS=daemon/logger/awslogs BUILDFLAGS=-race TESTFLAGS="-test.count 100" make test-unitCloses #22971