Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

Fix concurrent modification on logs and tags#500

Merged
pavolloffay merged 3 commits intojaegertracing:masterfrom
pavolloffay:fix-concurrent-exception
Jul 24, 2018
Merged

Fix concurrent modification on logs and tags#500
pavolloffay merged 3 commits intojaegertracing:masterfrom
pavolloffay:fix-concurrent-exception

Conversation

@pavolloffay
Copy link
Copy Markdown
Member

Fixes #334

Signed-off-by: Pavol Loffay ploffay@redhat.com

@ghost ghost assigned pavolloffay Jul 20, 2018
@ghost ghost added the review label Jul 20, 2018
JaegerSpan span = tracer.buildSpan("foo").start();
span.log("foo");
for (LogData log: span.getLogs()) {
span.log("foo2");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this test failing when ran against the current master?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think so

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 20, 2018

Codecov Report

Merging #500 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #500      +/-   ##
===========================================
- Coverage     88.21%   88.2%   -0.02%     
  Complexity      498     498              
===========================================
  Files            65      65              
  Lines          1859    1848      -11     
  Branches        242     239       -3     
===========================================
- Hits           1640    1630      -10     
  Misses          141     141              
+ Partials         78      77       -1
Impacted Files Coverage Δ Complexity Δ
...ain/java/io/jaegertracing/internal/JaegerSpan.java 93.45% <100%> (+0.53%) 47 <4> (+1) ⬆️
...c/main/java/io/jaegertracing/internal/LogData.java 100% <100%> (ø) 4 <1> (-1) ⬇️

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 efd00c9...0ff892f. Read the comment docs.

this.startTimeNanoTicks = startTimeNanoTicks;
this.computeDurationViaNanoTicks = computeDurationViaNanoTicks;
this.tags = new HashMap<String, Object>();
this.tags = new ConcurrentHashMap<String, Object>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we could also remove the synchronized from the tags getter.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it could be removed from other methods too. I will rather do it in a separate PR with more concurrent test and keep this clear. synchronized was not related to the concurrent modifications in this case.

@yurishkuro
Copy link
Copy Markdown
Member

I am not clear why copy on write is better than normal synchronization.

@bygui86
Copy link
Copy Markdown

bygui86 commented Jul 23, 2018

@pavolloffay I've just commented on the issue #334 with an update on my repo.
Thanks guys :)

@pavolloffay
Copy link
Copy Markdown
Member Author

thanks @bygui86, I will fix this anyway as it's a bug

@bygui86
Copy link
Copy Markdown

bygui86 commented Jul 23, 2018

Thanks a lot @pavolloffay :)
My way is just a workaround to wait for your fix :)

@pavolloffay pavolloffay force-pushed the fix-concurrent-exception branch from 7e094ca to 2dc6656 Compare July 23, 2018 16:44
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@pavolloffay pavolloffay force-pushed the fix-concurrent-exception branch from 2dc6656 to 0005f5e Compare July 23, 2018 16:45
@pavolloffay
Copy link
Copy Markdown
Member Author

@yurishkuro @vprithvi I have changed PR to use only wrap the collection in getters.

In the next PR I will try to get rid of synchronizing on this with a test validating better performance.

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Copy link
Copy Markdown
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

The changes in getters make sense, what was the change to log methods about? Just refactoring?

private final Map<String, ?> fields;

LogData(long time, String message) {
LogData(long time, Map<String, ?> fields, String message) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I would have preferred the message parameter to come before fields

return log(timestampMicroseconds, null, event);
}

private JaegerSpan log(long timestampMicroseconds, Map<String, ?> fields, String event) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I would have preferred the message parameter to come before fields

@pavolloffay
Copy link
Copy Markdown
Member Author

Just refactoring, I think the current version is cleaner - only one method for processing logs. I will update PR to change the parameter order and merge if nobody objects

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants