This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Tow/implement new cassandra exception #7353
Open
tillyow
wants to merge
23
commits into
develop
Choose a base branch
from
tow/implement-new-cassandra-exception
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
bf9b64b
Added CassandraTException
tillyow fcfcdd4
Adding missedTExceptions
tillyow 73922f5
spotlessApply
tillyow 5ca86f7
Added UnavailableException catches
tillyow e49373c
Add generated changelog entries
svc-changelog a64466c
Ammended the CassadraException to include args as the other PR will i…
tillyow 6907c90
Merge branch 'tow/implement-new-cassandra-exception' of https://githu…
tillyow 4ece409
Amended compileTime
tillyow d0d672f
explainer for compile time suppression
tillyow cb31c35
Merge branch 'develop' into tow/implement-new-cassandra-exception
tillyow a7cc461
typo
tillyow d269d60
Api break confirmation not a break as break has been fixed via same PR
tillyow b0ee926
spoteless
tillyow 86d55f3
Added a catch for a TEXception
tillyow fda40b5
change exception caught
tillyow 49fb7e1
Change to catch AtlasDbDependency excpetion
tillyow bebe35e
Exception now throws AtlasDbException so adapting the integration test
tillyow fd5737b
Merge branch 'develop' into tow/implement-new-cassandra-exception
tillyow 2245e01
test changed for new exception thrown
tillyow 97c2bde
Merge branch 'tow/implement-new-cassandra-exception' of https://githu…
tillyow 87149e6
added requested changes:
tillyow 185f04e
Change the compaction wording
tillyow cd6fbfa
spotlessApply
tillyow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,13 +36,13 @@ void testSetup(CassandraKeyValueService kvs) { | |
|
||
@Test | ||
public void deletingThrows() { | ||
assertThrowsInsufficientConsistencyExceptionAndDoesNotChangeCassandraSchema( | ||
assertThrowsAtlasDbDependencyExceptionAndDoesNotChangeCassandraSchema( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems odd - why do we need to change this? We should still be throwing InsufficientConsistencyExceptions here. |
||
() -> getTestKvs().delete(TEST_TABLE, ImmutableMultimap.of(CELL_1_1, TIMESTAMP))); | ||
} | ||
|
||
@Test | ||
public void deleteAllTimestampsThrows() { | ||
assertThrowsInsufficientConsistencyExceptionAndDoesNotChangeCassandraSchema(() -> getTestKvs() | ||
assertThrowsAtlasDbDependencyExceptionAndDoesNotChangeCassandraSchema(() -> getTestKvs() | ||
.deleteAllTimestamps( | ||
TEST_TABLE, | ||
ImmutableMap.of( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,8 +137,14 @@ private CassandraClient instrumentClient(Client rawClient) { | |
return client; | ||
} | ||
|
||
private Cassandra.Client getRawClientWithKeyspaceSet() throws TException { | ||
Client ret = getRawClientWithTimedCreation(); | ||
private Cassandra.Client getRawClientWithKeyspaceSet() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should be changing the signature here - this should be an invisible refactor, and changing the fact that this no longer throws the checked exception is changing the signature. Do double check whether you actually want to modify here to remap the exception, or at the caller (and let me know what you believe to be the case) |
||
Client ret; | ||
try { | ||
ret = getRawClientWithTimedCreation(); | ||
} catch (TException e) { | ||
throw CassandraTExceptions.mapToUncheckedException(e); | ||
} | ||
|
||
try { | ||
ret.set_keyspace(clientConfig.keyspace()); | ||
if (log.isDebugEnabled()) { | ||
|
@@ -154,7 +160,10 @@ private Cassandra.Client getRawClientWithKeyspaceSet() throws TException { | |
return ret; | ||
} catch (TException e) { | ||
ret.getOutputProtocol().getTransport().close(); | ||
throw e; | ||
throw CassandraTExceptions.mapToUncheckedException( | ||
"Failed to create new client for: {}", | ||
e, | ||
SafeArg.of("address", CassandraLogHelper.host(cassandraServer.proxy()))); | ||
} | ||
} | ||
|
||
|
@@ -228,8 +237,8 @@ private static Cassandra.Client getRawClient( | |
addr); | ||
} catch (TException e) { | ||
client.getOutputProtocol().getTransport().close(); | ||
log.error("Exception thrown attempting to authenticate with config provided credentials", e); | ||
throw e; | ||
throw CassandraTExceptions.mapToUncheckedException( | ||
"Exception thrown attempting to authenticate with config provided credentials", e); | ||
} | ||
|
||
return client; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraTExceptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* (c) Copyright 2024 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.keyvalue.cassandra; | ||
|
||
import com.google.errorprone.annotations.CompileTimeConstant; | ||
import com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException; | ||
import com.palantir.common.exception.AtlasDbDependencyException; | ||
import com.palantir.logsafe.Arg; | ||
import org.apache.cassandra.thrift.TimedOutException; | ||
import org.apache.cassandra.thrift.UnavailableException; | ||
|
||
public final class CassandraTExceptions { | ||
private CassandraTExceptions() {} | ||
|
||
public static AtlasDbDependencyException mapToUncheckedException( | ||
@CompileTimeConstant final String logMessage, Throwable throwable, Arg<?>... args) { | ||
if (throwable instanceof TimedOutException) { | ||
return new CassandraTimedOutException(throwable, args); | ||
} | ||
if (throwable instanceof UnavailableException) { | ||
return new InsufficientConsistencyException(logMessage, throwable); | ||
} | ||
if (throwable instanceof InsufficientConsistencyException) { | ||
return new InsufficientConsistencyException(logMessage, throwable); | ||
} | ||
return new AtlasDbDependencyException(throwable); | ||
} | ||
|
||
public static AtlasDbDependencyException mapToUncheckedException(Throwable throwable, Arg<?>... args) { | ||
if (throwable instanceof TimedOutException) { | ||
return new CassandraTimedOutException(throwable, args); | ||
} | ||
if (throwable instanceof UnavailableException) { | ||
return new InsufficientConsistencyException(throwable, args); | ||
} | ||
return new AtlasDbDependencyException(throwable, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...dra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraTimedOutException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* (c) Copyright 2024 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.keyvalue.cassandra; | ||
|
||
import com.palantir.common.exception.AtlasDbDependencyException; | ||
import com.palantir.logsafe.Arg; | ||
import com.palantir.logsafe.exceptions.SafeExceptions; | ||
|
||
// Added the below suppression because the Runtime class compileTime string check sees the + in the static final as | ||
// non compile time safe. But no other way to achieve as we are using a java version that does not have text blocks. | ||
tillyow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@SuppressWarnings("CompileTimeConstant") | ||
public class CassandraTimedOutException extends AtlasDbDependencyException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private static final String LOG_MESSAGE = | ||
"Cassandra query threw a TimedOut exception. Possible reasons and actions to resolve include:\n" | ||
+ "1. Reason: AtlasDB clients are requesting too much data from Cassandra.\n" | ||
+ " Resolution: Change the query to request less data.\n" | ||
+ "2. Reason: Data that has been deleted is being read in the query (e.g. A large amount of" | ||
+ " tombstones).\n" | ||
+ " Resolution: Check the status of sweep for your client, and if required run a compaction on your" | ||
+ " Cassandra server.\n" | ||
+ "3. Reason: Cassandra is struggling, possibly due to another large query, server health issues, or a" | ||
+ " network outage.\n" | ||
+ " Resolution: Ask your CassandraOps to check the state of the Cassandra server."; | ||
|
||
public CassandraTimedOutException(Throwable throwable, Arg<?>... args) { | ||
super(SafeExceptions.renderMessage(LOG_MESSAGE, args), throwable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
note: This would be true for truly internal APIs. However, this exception is actually used in the internal backup and restore product's tests. It's probably not a major issue, but we will want to make sure that we fix their tests and bump their Atlas version accordingly.
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.
I did a sourcegraph check, and I couldn't find anything. How would I see the usages of "internal backup and restore product's tests" if not using sourcegraph?