Skip to content

Commit

Permalink
Fixed record latency before recycling in broker-side producer handler (
Browse files Browse the repository at this point in the history
…apache#4309)

### Motivation

In apache#4290 the latency was collected after the context object is triggered in a separate thread. By the time we try to use the producer object it might have been already recycled.
  • Loading branch information
merlimat authored and sijie committed May 20, 2019
1 parent 58986a8 commit cacb16a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ public void completed(Exception exception, long ledgerId, long entryId) {

this.ledgerId = ledgerId;
this.entryId = entryId;
producer.cnx.ctx().channel().eventLoop().execute(this);
producer.topic.recordAddLatency(TimeUnit.NANOSECONDS.toMicros(System.nanoTime() - startTimeNs));
producer.cnx.ctx().channel().eventLoop().execute(this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public class PersistentTopic implements Topic, AddEntryCallback {
SchemaCompatibilityStrategy.FULL;
// schema validation enforced flag
private volatile boolean schemaValidationEnforced = false;
private StatsBuckets addEntryLatencyStatsUsec = new StatsBuckets(ENTRY_LATENCY_BUCKETS_USEC);
private final StatsBuckets addEntryLatencyStatsUsec = new StatsBuckets(ENTRY_LATENCY_BUCKETS_USEC);

private static final FastThreadLocal<TopicStatsHelper> threadLocalTopicStats = new FastThreadLocal<TopicStatsHelper>() {
@Override
Expand Down

0 comments on commit cacb16a

Please sign in to comment.