New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 2570: Update segment metrics when a transaction merge happens #3239
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis build is failing (StreamSegmentContainerTests
).
Codecov Report
@@ Coverage Diff @@
## master #3239 +/- ##
============================================
- Coverage 78.84% 78.81% -0.03%
+ Complexity 8016 8015 -1
============================================
Files 609 609
Lines 31476 31479 +3
Branches 3041 3042 +1
============================================
- Hits 24816 24810 -6
- Misses 4870 4876 +6
- Partials 1790 1793 +3
Continue to review full report at Codecov.
|
@@ -493,6 +504,13 @@ public boolean isOffline() { | |||
// the Merge right after the Seal. | |||
result = CompletableFuture.allOf(result, | |||
this.durableLog.add(new MergeSegmentOperation(targetSegmentId, sourceSegmentId), timer.getRemaining())); | |||
//if segment is a transaction, add its length onto metrics of target segment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good idea to place this kind of metrics logic in upper layers whenever possible. For this reason, it would be nice to explore if it is possible to report these metrics in PravegaRequestProcessor.mergeSegments
(there is a private method recordStatForTransaction
in which you can add your reporting logic).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
I am OK with this, but just FYI that we use that metric to measure ingestion throughput. Since the data for transactions has already been reported, we will get throughput spikes for every transaction merge, even if we did not actually ingest any data. |
@andreipaduroiu yes this approach will cause spike for segment level throughput. Hopefully the situation is mitigated by the global WRITE_BYTES and WRITE_EVENTS metrics as these two are reported regardless. |
522e94e
to
2107d98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (just a couple of minor comments).
@Slf4j | ||
public class TransactionMetricsTest { | ||
|
||
private final int controllerPort = TestUtils.getAvailableListenPort(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: indentation in this class seems to be the half of what it should be, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -623,6 +625,13 @@ private void recordStatForTransaction(SegmentProperties sourceInfo, String targe | |||
if (statsRecorder != null) { | |||
statsRecorder.merge(targetSegmentName, len, numOfEvents, creationTime); | |||
} | |||
|
|||
//if source segment is a transaction, add its length and event count onto metrics of target segment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, according to our guidelines, comments start by space and capitals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
04f28a0
to
f95f023
Compare
Signed-off-by: kevinhan88 <kevinhan88@gmail.com>
…since some ad-hoc code may skip it Signed-off-by: kevinhan88 <kevinhan88@gmail.com>
Signed-off-by: kevinhan88 <kevinhan88@gmail.com>
Signed-off-by: kevinhan88 <kevinhan88@gmail.com>
f95f023
to
df25e71
Compare
Signed-off-by: kevinhan88 <kevinhan88@gmail.com>
df25e71
to
387c0b7
Compare
field.set(null, newValue); | ||
} | ||
|
||
SegmentProperties createSegmentProperty(String streamSegmentName, UUID txnId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use StreamSegmentInformation.builder(). …. build()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
statsProvider.start(); | ||
log.info("Metrics Stats provider is started"); | ||
|
||
executor = Executors.newSingleThreadScheduledExecutor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derive this class from ThreadPooledTestSuite
and override getThreadPoolSize
. That will take care of creating executors and properly shutting them down for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire test has been replaced by light weight mock tests.
updatedCounter = true; | ||
} catch (AssertionError e) { | ||
log.info("Metric not updated in the cache. Retrying.", e); | ||
Exceptions.handleInterrupted(() -> Thread.sleep(100)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no better way of doing this than using a busy-wait loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, we shouldn't have too many unit integration tests - as of today it already takes over 40 minutes to finish all unit tests.
I've deleted this integration test, and added some mock tests.
@@ -1,20 +1,23 @@ | |||
/** | |||
* Copyright (c) 2017 Dell Inc., or its subsidiaries. All Rights Reserved. | |||
* | |||
* <p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove these markers from the license header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
a068d50
to
57cb508
Compare
Signed-off-by: kevinhan88 <kevinhan88@gmail.com>
57cb508
to
bc73bda
Compare
* master: (31 commits) Issue 3279: Client is performing blocking operations inside Netty Event Loop (pravega#3280) Issue 3200: Document Review: wire-protocol.md (pravega#3201) Issue 2933: (SegmentStore) testEndToEndWithFencing fixes (pravega#3294) Issue pravega#2768: Rename PravegaCredsWrapper class and its member variable (pravega#3302) Issue pravega#3299: Reduce dependencies in client (pravega#3300) Issue 2895: Wire Protocol implementation for TableStore (pravega#3283) Issue-3239: Make DYNAMIC_LOGGER non-static (pravega#3293) Issue 2956: (SegmentStore) TableSegment.deleteIfEmpty (pravega#3263) Issue pravega#3289: Use compile-time dependencies where possible (pravega#3290) Issue 3223: RetentionTest failure (pravega#3272) Issue 2001: Make a defensive copy of streamCut's position map (pravega#3281) Issue 3287: Exclude "passwd" extensions from rat. (pravega#3288) Issue 3285: Changed image pull policy. (pravega#3286) Issue 3266: Ensure bookkeeper.bkAckQuorumSize is 3 for BookieFailover test. (pravega#3267) Issue 3264: Return a SegmentHandle from Storage create method. (pravega#3276) Issue 3086: Controller Diagrams(new) included (pravega#3097) Issue 2570: Update segment metrics when a transaction merge happens (pravega#3239) Issue 3149: (SegmentStore) Pinned Segments (pravega#3215) Issue 3269: Fix invalid initialization order in AbstractScaleTests. (pravega#3270) Issue 3148: (Segment Store) Segment Metadata Store (pravega#3206) ...
Signed-off-by: kevinhan88 kevinhan88@gmail.com
Change log description
Transaction segment write_bytes and write_events will only be added into parent segment metrics when transaction segments merge happens.
Purpose of the change
Fixes #2570
What the code does
Inside StreamSegmentContainer.java when mergeStreamSegment() is called, if the sourceSegment is not empty and is a transaction segment, then:
.the length of source segment is added into the WRITE_BYTES metrics of target segment
.the event count of source segment is added into the WRITE_EVENTS metrics of target segment
How to verify it
Integration unit test included.
Can also be observed in live metrics: after txn commit, the metrics of parent segment changes; if txn is aborted, no change to the parent segment.