Skip to content
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

GEODE-6588: Fixed mismatch of placeholders and arguments #7375

Merged
merged 1 commit into from
Jun 1, 2022

Conversation

nabarunnag
Copy link
Contributor

  • Logging calls with number of placeholder not equal to the number of
    arguments were fixed in this PR.

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Has your PR been rebased against the latest commit within the target branch (typically develop)?

  • Is your initial contribution a single, squashed commit?

  • Does gradlew build run cleanly?

  • Have you written or updated unit tests to verify your changes?

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

@@ -328,8 +328,8 @@ protected void basicPerformTimeout(boolean isPending) throws CacheException {
if (logger.isTraceEnabled()) {
// NOTE: original finer message used this.toString() twice
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't this comment is necessary anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will remove

@@ -1257,7 +1257,7 @@ boolean canAccommodateMoreBytesSafely(int bytes) {
final long curBytes = bytesInUse.get();
if (isDebugEnabled) {
logger.debug(
"canAccomodateMoreBytes: bytes = {} allocatedMemory = {} newAllocatedSize = {} thresholdSize = ",
"canAccomodateMoreBytes: bytes ={} allocatedMemory ={} newAllocatedSize ={} thresholdSize ={}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Was it intentional to remove the whitespace here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

was trying to keep the spacing unform in a way. There are no spaces in ':{}' (sometimes they do) hence was trying to keep things uniform.

Copy link
Contributor

Choose a reason for hiding this comment

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

If removing whitespace, x=5 y=7 seems more natural than x =5 y =7 🤷‍♂️

@@ -3022,7 +3022,7 @@ public void handleInterestEvent(InterestRegistrationEvent event) {
// If this is a registration event, add interest for this key
if (isRegister) {
if (logger.isDebugEnabled()) {
logger.debug("PartitionedRegionDataStore for {} adding interest for: ",
logger.debug("PartitionedRegionDataStore for {} adding interest for :{}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace change seems wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we search for :{} in the project, we see that it is being used. I remember all logs I analyzed in hydra we used this format. Helps in easier greps

@@ -462,7 +462,7 @@ public static void send(InternalDistributedMember recipient, int processorId,
if (exception != null) {
m.setException(exception);
if (logger.isDebugEnabled()) {
logger.debug("Replying with exception: {}" + m, exception);
logger.debug("Replying with exception:{}", m, exception);
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if the intent was for just the exception message here and not the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is safe as it is inside debug flag

@@ -98,7 +98,7 @@ public synchronized void lastResult(Object oneResult) {
}

if (logger.isDebugEnabled()) {
logger.debug("ServerToClientFunctionResultSender sending last result1 {} " + oneResult);
logger.debug("ServerToClientFunctionResultSender sending last result1 {} ", oneResult);
Copy link
Contributor

Choose a reason for hiding this comment

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

Trailing whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will fix

logger.warn("Unable to schedule background cleanup of transactions for departed member {}."
+ " Performing in-line cleanup of the transactions.");
logger.warn(
"Unable to schedule background cleanup of transactions for departed member. Performing in-line cleanup of the transactions.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a member to log here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

found it. adding it to the log

Copy link
Contributor

@upthewaterspout upthewaterspout left a comment

Choose a reason for hiding this comment

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

I think you accidentally picked up all of the places where we are trying to log the full stack of an exception.

For example - this was correct and will log the full stack trace

logger.debug("I saw an exception", e)

But you changed many of these to this, which will lose the whole stack trace:

logger.debug("I saw an exception {}", e)

Copy link
Contributor

@upthewaterspout upthewaterspout left a comment

Choose a reason for hiding this comment

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

Sorry Naba - I was reading those messages backwards.

Copy link
Contributor

@onichols-pivotal onichols-pivotal left a comment

Choose a reason for hiding this comment

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

comment deleted

Copy link
Contributor

@dschneider-pivotal dschneider-pivotal left a comment

Choose a reason for hiding this comment

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

I had a few comments for you to consider but didn't see anything that had to be changed. It does seem like a common theme is confusion about the last parameter and if it should be logged as an exception stack or just part of the message. It seems like our use of the log4j Logger interface would make it hard to cleanup this ambiguity.

@@ -5126,8 +5126,8 @@ public static void validatePRID(InternalDistributedMember sender, int prId, Stri
PartitionedRegion pr = (PartitionedRegion) o;
if (pr.getPRId() == prId) {
if (!pr.getRegionIdentifier().equals(regionId)) {
logger.warn("{} is using PRID {} for {} but this process maps that PRID to {}",
new Object[] {sender.toString(), prId, pr.getRegionIdentifier()});
logger.warn("{} is using PRID {} for regionId {} but this process maps that PRID to {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

could "sender.toString()" just be "sender"? This will improve performance if warnings are disabled (which is unlikely).

@@ -5613,7 +5613,7 @@ public void cleanupFailedInitialization() {
}
if (savedFirstRuntimeException != null
&& savedFirstRuntimeException instanceof DistributedSystemDisconnectedException) {
logger.warn("cleanupFailedInitialization originally failed with {}",
logger.warn("cleanupFailedInitialization originally failed with: ",
Copy link
Contributor

Choose a reason for hiding this comment

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

Did the old code for this warning log the call stack for savedFirstRuntimeException? It looks like the intent was just to log savedFirstRuntimeException.toString() inside the curly brackets.
But if the old behavior was to log the stack then I think your change is good.

All the places we consider setting savedFirstRuntimeException we also log a warning with the full stack. So I think that intent of this message was just to say "cleanup actually did fail and here is the exception of all the ones we already logged that caused the failure". It seems odd to me that these are warnings. I'm not sure what a customer could do with these warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like having the stack on warnings.

@@ -72,7 +72,7 @@ public void cmdExecute(final @NotNull Message clientMessage,
String regionName = regionNamePart.getCachedString();

if (regionName == null) {
logger.warn("The input region name for the %s request is null", "size");
logger.warn("The input region name for the size request is null");
Copy link
Contributor

Choose a reason for hiding this comment

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

while you are in this part of the code consider fixing the errMessage.append call also. It seems like we should just have a local String constant that is in both calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done with #7399

Copy link
Contributor

@boglesby boglesby left a comment

Choose a reason for hiding this comment

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

A couple minor comments.

@@ -5613,7 +5613,7 @@ public void cleanupFailedInitialization() {
}
if (savedFirstRuntimeException != null
&& savedFirstRuntimeException instanceof DistributedSystemDisconnectedException) {
logger.warn("cleanupFailedInitialization originally failed with {}",
logger.warn("cleanupFailedInitialization originally failed with: ",
Copy link
Contributor

Choose a reason for hiding this comment

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

I like having the stack on warnings.

@@ -2953,7 +2953,7 @@ public void executeOnDataStore(final Set localKeys, final Function function, fin
long start = stats.startFunctionExecution(function.hasResult());
try {
if (logger.isDebugEnabled()) {
logger.debug("Executing Function: {} on Remote Node with context: ", function.getId(),
logger.debug("Executing Function:{} on Remote Node with context: {}", function.getId(),
Copy link
Contributor

Choose a reason for hiding this comment

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

The space was removed in Function:{}. It probably should also be removed in context: {}

@@ -146,7 +146,7 @@ private void initializeEventSeqNumQueue() {

if (logger.isDebugEnabled()) {
logger.debug(
"For bucket {} ,total keys recovered are : {} last key recovered is : {} and the seqNo is ",
"For bucket: {} ,total keys recovered are: {} last key recovered is: {} and the seqNo is: {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

This: {} , should be this: {}, . Also there are no commas in the rest of that message, so maybe the comma should be removed altogether.

Copy link
Contributor

@jchen21 jchen21 left a comment

Choose a reason for hiding this comment

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

I recommend some minor changes.

@@ -393,7 +393,7 @@ public static void send(InternalDistributedMember recipient, int processorId,
if (exception != null) {
m.setException(exception);
if (logger.isDebugEnabled()) {
logger.debug("Replying with exception: {}" + m, exception);
logger.debug("Replying with exception: {}", m, exception);
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing {} here.

@@ -462,7 +462,7 @@ public static void send(InternalDistributedMember recipient, int processorId,
if (exception != null) {
m.setException(exception);
if (logger.isDebugEnabled()) {
logger.debug("Replying with exception: {}" + m, exception);
logger.debug("Replying with exception: {}", m, exception);
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing {} here.

logger.trace(
"{}.performTimeout().getExpirationTime() is {}; {}.expire({}). ttlExpiration: {}, idleExpiration: {}, ttlAttrs: {}, idleAttrs: {} action is: {}",
this, expTime, this, action, ttl, idle, getTTLAttributes(), getIdleAttributes());
"{}.performTimeout().getExpirationTime() is {}; ttlExpiration:{}, idleExpiration:{}, ttlAttrs:{}, idleAttrs:{} action is:{}",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is passed as parameter for {}.performTimeout().getExpirationTime(). It will call EntryExpiryTask.toString() which returns a long string description with spaces. It is not easy to read. Perhaps passing this.getClass().getSimpleName() would be better. And the method name should be basicPerformTimeout instead of performTimeout().

Copy link
Contributor

@Bill Bill left a comment

Choose a reason for hiding this comment

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

I reviewed the changes in files for which I'm code-owner. Those look perfect. Thanks for the changes @nabarunnag !

@nabarunnag
Copy link
Contributor Author

@boglesby I made sure that stacktrace is always printed in these changes
@dschneider-pivotal I switch to using .warn(String,Throwable) API which ensures the stack is printed as per javadoc

@nabarunnag nabarunnag merged commit 992208e into apache:develop Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet