Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

[TEX] Part 7: wiring data collection #6340

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
d5cc1e9
copy pasta
ergo14 Oct 30, 2022
8a3eef0
adding expectations measuring utilities & tests
ergo14 Oct 30, 2022
037777e
adding keyvalueservice data tracker & tests
ergo14 Oct 30, 2022
b0f6609
adding iterators
ergo14 Oct 30, 2022
0f6b859
Merge branch 'tex-pr-1c0' into tex-pr-1d2
ergo14 Oct 30, 2022
f829968
Merge branch 'tex-pr-1d1' into tex-pr-1d2
ergo14 Oct 30, 2022
0dbad63
putting it all together
ergo14 Oct 30, 2022
49f106e
fix constructor
ergo14 Oct 30, 2022
89ae9f0
progress
ergo14 Oct 31, 2022
2c97dbf
progress
ergo14 Oct 31, 2022
4c7fb19
checkpoint
ergo14 Oct 31, 2022
87ce54b
more wiring
ergo14 Nov 1, 2022
f08fd07
stuff
ergo14 Nov 1, 2022
7375fb4
merge conflicts
ergo14 Nov 9, 2022
7712ccd
merge conflict
ergo14 Nov 11, 2022
5e2fc66
removing obsolete code
ergo14 Nov 11, 2022
b51745b
removing clock and impls
ergo14 Nov 14, 2022
c72a8f1
removing metrics definition
ergo14 Nov 14, 2022
76c4e62
removing getAgeMillisAndFreezeStopwatch
ergo14 Nov 14, 2022
86b882a
staging
ergo14 Nov 15, 2022
0271726
moving ExpectationsAwareTransaction
ergo14 Nov 15, 2022
6b7e898
merging
ergo14 Nov 15, 2022
ca02903
fix
ergo14 Nov 15, 2022
e346fe7
adding tracking data to ExpectationsAwareTransaction interface
ergo14 Nov 15, 2022
80974c9
Merge branch 'tex-pr-6' into tex-draft-1
ergo14 Nov 15, 2022
167f461
fixes
ergo14 Nov 15, 2022
cbbbfaf
removing stuff
ergo14 Nov 18, 2022
9c75713
Merge branch 'develop' into tex-pr-6
ergo14 Nov 18, 2022
a60e8d9
merge
ergo14 Nov 18, 2022
bfa1f8d
javadoc removal
ergo14 Nov 18, 2022
81af9bd
javadoc removal
ergo14 Nov 18, 2022
7f1e296
removing config
ergo14 Nov 18, 2022
e399a3e
Merge branch 'tex-pr-6' into tex-draft-1
ergo14 Nov 18, 2022
e688370
impl
ergo14 Nov 18, 2022
60a607e
remove test
ergo14 Nov 21, 2022
8474c57
Merge branch 'tex-pr-6' into tex-draft-1
ergo14 Nov 21, 2022
e2892da
yml metrics spec
ergo14 Nov 21, 2022
9c77288
flups
ergo14 Nov 22, 2022
de1f185
Merge branch 'tex-pr-6' into tex-draft-1
ergo14 Nov 22, 2022
5552815
flup
ergo14 Nov 22, 2022
ce4ef5b
reportExpectationsCollectedData() no ops if called on in-progress tra…
ergo14 Nov 22, 2022
ab77a45
checkstyle
ergo14 Nov 22, 2022
986fde0
fixes
ergo14 Nov 22, 2022
9733e26
remove merge tokens
ergo14 Nov 22, 2022
247f3d8
Merge branch 'develop' into tex-draft-1
ergo14 Nov 23, 2022
5033e19
merge develop
ergo14 Nov 23, 2022
18be54b
Merge branch 'develop' into tex-draft-1
ergo14 Nov 23, 2022
7df9eca
pairing
ergo14 Nov 24, 2022
11d4c43
come one
ergo14 Nov 24, 2022
5390c75
yes
ergo14 Nov 24, 2022
dd465e3
Add generated changelog entries
svc-changelog Nov 24, 2022
ba63b23
Autorelease 0.773.0-rc1
ergo14 Nov 24, 2022
15836f4
revapi
ergo14 Nov 24, 2022
0c1e1f4
Autorelease 0.773.0-rc2
ergo14 Nov 24, 2022
2f08a45
debugging
ergo14 Nov 28, 2022
dfab6fb
fix
ergo14 Nov 28, 2022
8c7fd1a
Autorelease 0.773.0-rc3
ergo14 Nov 28, 2022
5680412
fix revapi
ergo14 Dec 6, 2022
480dae7
Autorelease 0.782.0-rc1
ergo14 Dec 6, 2022
8fbe122
more logs
ergo14 Dec 8, 2022
4238a7a
Autorelease 0.782.0-rc2
ergo14 Dec 8, 2022
6f2fc36
Merge branch 'develop' into tex-draft-1
ergo14 Jan 3, 2023
1a1873f
fixes
ergo14 Jan 3, 2023
2786dee
Autorelease 0.784.0-rc1
ergo14 Jan 3, 2023
7aaf6c2
Merge branch 'develop' into tex-draft-1
ergo14 Jan 12, 2023
c06bee3
changing the metric namespace name
ergo14 Jan 12, 2023
642761c
fix
ergo14 Jan 12, 2023
756e438
fix
ergo14 Jan 12, 2023
5598022
exclude metrics file from license
ergo14 Jan 12, 2023
908da7d
Autorelease 0.787.0-rc1
ergo14 Jan 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .palantir/revapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ acceptedBreaks:
- code: "java.class.removed"
old: "interface com.palantir.atlasdb.transaction.api.expectations.ExpectationsStatistics"
justification: "removing TEX until ready"
"0.772.0":
com.palantir.atlasdb:atlasdb-api:
- code: "java.class.removed"
old: "interface com.palantir.atlasdb.transaction.api.expectations.ExpectationsAwareTransaction"
justification: "moving this out of API"
"0.774.0":
com.palantir.atlasdb:atlasdb-cassandra:
- code: "java.method.removed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected final <T, E extends Exception> T runTaskThrowOnConflictWithCallback(
}
} finally {
callback.run();
txn.reportExpectationsCollectedData();
txn.runSuccessCallbacksIfDefinitivelyCommitted();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.palantir.atlasdb.transaction.impl;

import com.palantir.atlasdb.transaction.api.PreCommitCondition;
import com.palantir.atlasdb.transaction.api.Transaction;
import com.palantir.atlasdb.transaction.api.TransactionFailedException;
import com.palantir.atlasdb.transaction.service.TransactionService;

Expand All @@ -26,7 +25,7 @@
* are run. This can be used to e.g run {@link PreCommitCondition#cleanup()} <i>before</i> the onSuccess callbacks
* are run.
*/
public interface CallbackAwareTransaction extends Transaction {
public interface CallbackAwareTransaction extends ExpectationsAwareTransaction {
void commitWithoutCallbacks() throws TransactionFailedException;

void commitWithoutCallbacks(TransactionService transactionService) throws TransactionFailedException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

package com.palantir.atlasdb.transaction.api.expectations;
package com.palantir.atlasdb.transaction.impl;

import com.palantir.atlasdb.transaction.api.Transaction;
import com.palantir.atlasdb.transaction.api.expectations.TransactionReadInfo;

/**
* Implementors of this interface provide methods useful for tracking transactional expectations and whether
* they were breached as well as relevant metrics and alerts. Transactional expectations represent transaction-level
* limits and rules for proper usage of AtlasDB transactions (e.g. reading too much data overall).
* Todo(aalouane): move this out of API once part 4 is merged
*/
public interface ExpectationsAwareTransaction extends Transaction {
long getAgeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.palantir.atlasdb.transaction.api.TransactionFailedException;
import com.palantir.atlasdb.transaction.service.TransactionService;

public abstract class ForwardingCallbackAwareTransaction extends ForwardingTransaction
public abstract class ForwardingCallbackAwareTransaction extends ForwardingExpectationsAwareTransaction
implements CallbackAwareTransaction {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.palantir.atlasdb.transaction.impl;

import com.palantir.atlasdb.transaction.api.expectations.TransactionReadInfo;

public abstract class ForwardingExpectationsAwareTransaction extends ForwardingTransaction
implements ExpectationsAwareTransaction {

@Override
public abstract ExpectationsAwareTransaction delegate();

@Override
public long getAgeMillis() {
return delegate().getAgeMillis();
}

@Override
public TransactionReadInfo getReadInfo() {
return delegate().getReadInfo();
}

@Override
public void reportExpectationsCollectedData() {
delegate().reportExpectationsCollectedData();
}
}
1 change: 1 addition & 0 deletions atlasdb-impl-shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license {
exclude '**/PutUnlessExistsTableMetrics.java'
exclude '**/TargetedSweepProgressMetrics.java'
exclude '**/TimestampCorrectnessMetrics.java'
exclude '**/ExpectationsMetrics.java'
exclude '**/VerificationModeMetrics.java'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
import com.palantir.atlasdb.transaction.api.TransactionLockAcquisitionTimeoutException;
import com.palantir.atlasdb.transaction.api.TransactionLockTimeoutException;
import com.palantir.atlasdb.transaction.api.TransactionReadSentinelBehavior;
import com.palantir.atlasdb.transaction.api.expectations.TransactionReadInfo;
import com.palantir.atlasdb.transaction.expectations.ExpectationsMetrics;
import com.palantir.atlasdb.transaction.impl.expectations.TrackingKeyValueService;
import com.palantir.atlasdb.transaction.impl.expectations.TrackingKeyValueServiceImpl;
import com.palantir.atlasdb.transaction.impl.metrics.TableLevelMetricsController;
import com.palantir.atlasdb.transaction.impl.metrics.TransactionOutcomeMetrics;
import com.palantir.atlasdb.transaction.knowledge.TransactionKnowledgeComponents;
Expand Down Expand Up @@ -216,7 +220,7 @@ private enum State {

protected final TimelockService timelockService;
protected final LockWatchManagerInternal lockWatchManager;
final KeyValueService keyValueService;
final TrackingKeyValueService keyValueService;
final AsyncKeyValueService immediateKeyValueService;
final TransactionService defaultTransactionService;
private final AsyncTransactionService immediateTransactionService;
Expand Down Expand Up @@ -266,14 +270,16 @@ private enum State {

protected final TransactionKnowledgeComponents knowledge;

private final ExpectationsMetrics expectationsDataCollectionMetrics;

/**
* @param immutableTimestamp If we find a row written before the immutableTimestamp we don't need to grab a read
* lock for it because we know that no writers exist.
* @param preCommitCondition This check must pass for this transaction to commit.
*/
/* package */ SnapshotTransaction(
MetricsManager metricsManager,
KeyValueService keyValueService,
KeyValueService delegateKeyValueService,
TimelockService timelockService,
LockWatchManagerInternal lockWatchManager,
TransactionService transactionService,
Expand Down Expand Up @@ -302,7 +308,7 @@ private enum State {
this.lockWatchManager = lockWatchManager;
this.conflictTracer = conflictTracer;
this.transactionTimerContext = getTimer("transactionMillis").time();
this.keyValueService = keyValueService;
this.keyValueService = new TrackingKeyValueServiceImpl(delegateKeyValueService);
this.immediateKeyValueService = KeyValueServices.synchronousAsAsyncKeyValueService(keyValueService);
this.timelockService = timelockService;
this.defaultTransactionService = transactionService;
Expand Down Expand Up @@ -338,6 +344,7 @@ private enum State {
timelockService,
immutableTimestamp,
knowledge);
this.expectationsDataCollectionMetrics = ExpectationsMetrics.of(metricsManager.getTaggedRegistry());
}

protected TransactionScopedCache getCache() {
Expand Down Expand Up @@ -2576,6 +2583,37 @@ private Multimap<TableReference, Cell> getCellsToScrubByTable(State expectedStat
return tableRefToCells;
}

@Override
public long getAgeMillis() {
return System.currentTimeMillis() - timeCreated;
}

@Override
public TransactionReadInfo getReadInfo() {
return keyValueService.getOverallReadInfo();
}

@Override
public void reportExpectationsCollectedData() {
if (!List.of(State.COMMITTED, State.ABORTED, State.FAILED).contains(state.get())) {
log.error(
"reportExpectationsCollectedData is called on an in-progress transaction",
Comment on lines +2598 to +2600
Copy link
Contributor

Choose a reason for hiding this comment

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

You can probably reuse some of the logic from ensureStillRunning() - it isn't the same, but there should be similar bits you can use :)

SafeArg.of("state", state.get()));
return;
}

long ageMillis = getAgeMillis();
TransactionReadInfo info = getReadInfo();

expectationsDataCollectionMetrics.ageMillis().update(ageMillis);
expectationsDataCollectionMetrics.bytesRead().update(info.bytesRead());
expectationsDataCollectionMetrics.kvsCalls().update(info.kvsCalls());

info.maximumBytesKvsCallInfo()
.ifPresent(kvsCallReadInfo ->
expectationsDataCollectionMetrics.worstKvsBytesRead().update(kvsCallReadInfo.bytesRead()));
}

private Timer getTimer(String name) {
return metricsManager.registerOrGetTimer(SnapshotTransaction.class, name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public <T, C extends PreCommitCondition, E extends Exception> T runTaskWithCondi
condition.cleanup();
throw e;
}

return openTransaction.finishWithCallback(
transaction -> task.execute(transaction, condition), condition::cleanup);
}
Expand Down Expand Up @@ -246,7 +247,7 @@ private OpenTransactionImpl(CallbackAwareTransaction delegate, LockToken immutab
}

@Override
public Transaction delegate() {
public CallbackAwareTransaction delegate() {
return delegate;
}

Expand Down
19 changes: 19 additions & 0 deletions atlasdb-impl-shared/src/main/metrics/expectations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
options:
javaPackage: 'com.palantir.atlasdb.transaction.expectations'

namespaces:
expectations:
docs: Data collection on transaction patterns
metrics:
bytesRead:
docs: Bytes read by a transaction through Atlas kvs read calls
type: histogram
kvsCalls:
docs: Number of Atlas kvs read calls made by a transaction
type: histogram
ageMillis:
docs: Elapsed duration in milliseconds for a transaction
type: histogram
worstKvsBytesRead:
docs: Most bytes read by a transaction in one Atlas kvs read call
type: histogram
7 changes: 7 additions & 0 deletions changelog/0.773.0-rc1/pr-6340.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: feature
feature:
description: |-
Transactional expectations: enables metrics collections for key value service read calls on transactions post-mortem.
Metrics tracked per transaction: transaction age, number of bytes read, number of Atlas kvs method queries and number of bytes read for the worse Atlas kvs call (one with the most bytes read).
links:
- https://github.com/palantir/atlasdb/pull/6340
5 changes: 5 additions & 0 deletions changelog/0.773.0-rc1/pr-6380.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Fix supplement for CoordinationAwareKnownConcludedTransactionsStore
links:
- https://github.com/palantir/atlasdb/pull/6380
7 changes: 7 additions & 0 deletions changelog/0.773.0-rc2/pr-6340.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: feature
feature:
description: |-
Transactional expectations: enables metrics collections for key value service read calls on transactions post-mortem.
Metrics tracked per transaction: transaction age, number of bytes read, number of Atlas kvs method queries and number of bytes read for the worse Atlas kvs call (one with the most bytes read).
links:
- https://github.com/palantir/atlasdb/pull/6340
5 changes: 5 additions & 0 deletions changelog/0.773.0-rc2/pr-6380.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Fix supplement for CoordinationAwareKnownConcludedTransactionsStore
links:
- https://github.com/palantir/atlasdb/pull/6380
7 changes: 7 additions & 0 deletions changelog/0.773.0-rc3/pr-6340.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: feature
feature:
description: |-
Transactional expectations: enables metrics collections for key value service read calls on transactions post-mortem.
Metrics tracked per transaction: transaction age, number of bytes read, number of Atlas kvs method queries and number of bytes read for the worse Atlas kvs call (one with the most bytes read).
links:
- https://github.com/palantir/atlasdb/pull/6340
5 changes: 5 additions & 0 deletions changelog/0.773.0-rc3/pr-6380.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Fix supplement for CoordinationAwareKnownConcludedTransactionsStore
links:
- https://github.com/palantir/atlasdb/pull/6380
7 changes: 7 additions & 0 deletions changelog/0.782.0-rc1/pr-6340.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: feature
feature:
description: |-
Transactional expectations: enables metrics collections for key value service read calls on transactions post-mortem.
Metrics tracked per transaction: transaction age, number of bytes read, number of Atlas kvs method queries and number of bytes read for the worse Atlas kvs call (one with the most bytes read).
links:
- https://github.com/palantir/atlasdb/pull/6340
7 changes: 7 additions & 0 deletions changelog/0.782.0-rc2/pr-6340.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: feature
feature:
description: |-
Transactional expectations: enables metrics collections for key value service read calls on transactions post-mortem.
Metrics tracked per transaction: transaction age, number of bytes read, number of Atlas kvs method queries and number of bytes read for the worse Atlas kvs call (one with the most bytes read).
links:
- https://github.com/palantir/atlasdb/pull/6340
7 changes: 7 additions & 0 deletions changelog/0.784.0-rc1/pr-6340.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: feature
feature:
description: |-
Transactional expectations: enables metrics collections for key value service read calls on transactions post-mortem.
Metrics tracked per transaction: transaction age, number of bytes read, number of Atlas kvs method queries and number of bytes read for the worse Atlas kvs call (one with the most bytes read).
links:
- https://github.com/palantir/atlasdb/pull/6340
7 changes: 7 additions & 0 deletions changelog/0.787.0-rc1/pr-6340.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: feature
feature:
description: |-
Transactional expectations: enables metrics collections for key value service read calls on transactions post-mortem.
Metrics tracked per transaction: transaction age, number of bytes read, number of Atlas kvs method queries and number of bytes read for the worse Atlas kvs call (one with the most bytes read).
links:
- https://github.com/palantir/atlasdb/pull/6340
7 changes: 7 additions & 0 deletions changelog/@unreleased/pr-6340.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: feature
feature:
description: |-
Transactional expectations: enables metrics collections for key value service read calls on transactions post-mortem.
Metrics tracked per transaction: transaction age, number of bytes read, number of Atlas kvs method queries and number of bytes read for the worse Atlas kvs call (one with the most bytes read).
links:
- https://github.com/palantir/atlasdb/pull/6340