Skip to content

MINOR: Update Trogdor ConnectionStressWorker status at the end of execution#6445

Merged
cmccabe merged 4 commits intoapache:trunkfrom
stanislavkozlovski:minor-improve-trogdor-connection-stress-worker-status
Mar 15, 2019
Merged

MINOR: Update Trogdor ConnectionStressWorker status at the end of execution#6445
cmccabe merged 4 commits intoapache:trunkfrom
stanislavkozlovski:minor-improve-trogdor-connection-stress-worker-status

Conversation

@stanislavkozlovski
Copy link
Copy Markdown
Contributor

I was testing this worker locally and found that it would not report correct numbers after it shutting down due to the durationMs passing.

Status before patch:

{"tasks":{"connect":{"state":"DONE","spec":{"class":"org.apache.kafka.trogdor.workload.ConnectionStressSpec","startMs":1552576318156,"durationMs":60000,"clientNode":["node0"],"bootstrapServers":"localhost:9092","targetConnectionsPerSec":100,"numThreads":10,"action":"CONNECT"},"startedMs":1552576318159,"doneMs":1552576378366,"cancelled":false,"status":{"totalConnections":4021,"totalFailedConnections":0,"connectsPerSec":100.19186205865498}}

"connect2":{"state":"RUNNING","spec":{"class":"org.apache.kafka.trogdor.workload.ConnectionStressSpec","startMs":1552576480870,"durationMs":60000,"clientNode":["node0"],"bootstrapServers":"localhost:9092","targetConnectionsPerSec":200,"numThreads":10,"action":"CONNECT"},"startedMs":1552576480870,"status":{"totalConnections":8021,"totalFailedConnections":0,"connectsPerSec":200.3797246995928}}}}

Status after patch:

"tasks":{"connect_newer1":{"state":"DONE","spec":{"class":"org.apache.kafka.trogdor.workload.ConnectionStressSpec","startMs":1552579728411,"durationMs":60000,"clientNode":["node0"],"bootstrapServers":"localhost:9092","targetConnectionsPerSec":100,"numThreads":10,"action":"CONNECT"},"startedMs":1552579728412,"doneMs":1552579788645,"cancelled":false,"status":{"totalConnections":6010,"totalFailedConnections":0,"connectsPerSec":100.19004434368019}}

"connect_newer2":{"state":"DONE","spec":{"class":"org.apache.kafka.trogdor.workload.ConnectionStressSpec","startMs":1552579472885,"durationMs":60000,"clientNode":["node0"],"bootstrapServers":"localhost:9092","targetConnectionsPerSec":200,"numThreads":10,"action":"CONNECT"},"startedMs":1552579472891,"doneMs":1552579533114,"cancelled":false,"status":{"totalConnections":11980,"totalFailedConnections":0,"connectsPerSec":200.31434973079624}}}}

doneFuture.complete("");
workerExecutor.shutdownNow();
workerExecutor.awaitTermination(1, TimeUnit.DAYS);
synchronized (ConnectionStressWorker.this) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Even though calling updateStatus() here is thread-safe, I think that using the lock here acts as a memory barrier and allows us to access the latest values of the variables. I very well might be wrong though and this may be superfluous

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.

It's not thread-safe without the synchronized, since we're accessing variables that need synchronization. But let's move the synchronized keyword into ConnectionStressWorker#updateStatus, as described above, since that's a bit cleaner

* Update the worker's status.
* This method should be called inside a lock on the ConnectionStressWorker object
*/
private void updateStatus(long lastTimeMs) {
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.

This function should be synchronized since it accesses totalConnections, totalFailedConnections, etc. which are only ever accessed under the lock.

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Mar 14, 2019

Thanks, @stanislavkozlovski . Great find. I left a few comments.

this.totalConnections = 0;
this.totalFailedConnections = 0;
this.startTimeMs = TIME.milliseconds();
synchronized (ConnectionStressWorker.this) {
Copy link
Copy Markdown
Contributor Author

@stanislavkozlovski stanislavkozlovski Mar 14, 2019

Choose a reason for hiding this comment

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

Had to add this here otherwise we got a FindBugs warning


IS | Inconsistent synchronization of org.apache.kafka.trogdor.workload.ConnectionStressWorker.nextReportTime; locked 66% of time
-- | --
  | Bug type IS2_INCONSISTENT_SYNC (click for details) In class org.apache.kafka.trogdor.workload.ConnectionStressWorkerField org.apache.kafka.trogdor.workload.ConnectionStressWorker.nextReportTimeSynchronized 66% of the timeUnsynchronized access at ConnectionStressWorker.java:[line 107]Synchronized access at ConnectionStressWorker.java:[line 124]Synchronized access at ConnectionStressWorker.java:[line 162]
IS | Inconsistent synchronization of org.apache.kafka.trogdor.workload.ConnectionStressWorker.startTimeMs; locked 50% of time
  | Bug type IS2_INCONSISTENT_SYNC (click for details) In class org.apache.kafka.trogdor.workload.ConnectionStressWorkerField org.apache.kafka.trogdor.workload.ConnectionStressWorker.startTimeMsSynchronized 50% of the timeUnsynchronized access at ConnectionStressWorker.java:[line 104]Synchronized access at ConnectionStressWorker.java:[line 120]
IS | Inconsistent synchronization of org.apache.kafka.trogdor.workload.ConnectionStressWorker.totalConnections; locked 66% of time
  | Bug type IS2_INCONSISTENT_SYNC (click for details) In class org.apache.kafka.trogdor.workload.ConnectionStressWorkerField org.apache.kafka.trogdor.workload.ConnectionStressWorker.totalConnectionsSynchronized 66% of the timeUnsynchronized access at ConnectionStressWorker.java:[line 102]Synchronized access at ConnectionStressWorker.java:[line 120]Synchronized access at ConnectionStressWorker.java:[line 120]
IS | Inconsistent synchronization of org.apache.kafka.trogdor.workload.ConnectionStressWorker.totalFailedConnections; locked 50% of time
  | Bug type IS2_INCONSISTENT_SYNC (click for details) In class org.apache.kafka.trogdor.workload.ConnectionStressWorkerField org.apache.kafka.trogdor.workload.ConnectionStressWorker.totalFailedConnectionsSynchronized 50% of the timeUnsynchronized access at ConnectionStressWorker.java:[line 103]Synchronized access at ConnectionStressWorker.java:[line 120]

(see IS2_INCONSISTENT_SYNC in http://findbugs.sourceforge.net/bugDescriptions.html)

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Mar 15, 2019

LGTM

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Mar 15, 2019

Failed test is kafka.api.UserQuotaTest.testThrottledProducerConsumer, which is not related to this change.

@cmccabe cmccabe merged commit f20f3c1 into apache:trunk Mar 15, 2019
jarekr pushed a commit to confluentinc/kafka that referenced this pull request Apr 18, 2019
* apache/trunk:
  MINOR: Retain public constructors of classes from public API (apache#6455)
  KAFKA-8118; Ensure ZK clients are closed in tests, fix verification (apache#6456)
  KAFKA-7813: JmxTool throws NPE when --object-name is omitted
  KAFKA-8114: Wait for SCRAM credential propagation in DelegationTokenEndToEndAuthorizationTest (apache#6452)
  KAFKA-8111; Set min and max versions for Metadata requests (apache#6451)
  KAFKA-7855: Kafka Streams Maven Archetype quickstart fails to compile out of the box (apache#6194)
  MINOR: Update code to not use deprecated methods (apache#6434)
  MINOR: Update Trogdor ConnectionStressWorker status at the end of execution (apache#6445)
  KAFKA-8091; Use commitSync to check connection failure in listener update test (apache#6450)
  KAFKA-7027: Add an overload build method in scala (apache#6373)
  MINOR: Fix typos in LogValidator (apache#6449)
  KAFKA-7502: Cleanup KTable materialization logic in a single place (apache#6174)
  KAFKA-7730; Limit number of active connections per listener in brokers (KIP-402)
  KAFKA-8091; Remove unsafe produce from dynamic listener update test (apache#6443)
  MINOR: Fix JavaDocs warnings (apache#6435)
  MINOR: Better messaging for invalid fetch response (apache#6427)
  MINOR: Use Java 8 lambdas in KStreamImplTest (apache#6430)
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…cution (apache#6445)

Reviewers: Colin P. McCabe <cmccabe@apache.org>
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