Skip to content

Conversation

@alex-plekhanov
Copy link
Contributor

No description provided.

private final ClientBinaryMarshaller marsh;

/** Current thread transaction. */
private final ThreadLocal<TcpClientTransaction> tx = new ThreadLocal<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we have a possible memory leak here. TcpClientTransaction has a reference to TcpClientTransactions which has a reference to ThreadLocal<TcpClientTransaction> tx. If some TcpClientTransactions are not in use anymore but left a value in thread-local that value and TcpClientTransactions instance will never be garbage-collected. Making TcpClientTransaction class static should protect from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't make TcpClientTransaction static, because we need TcpClientTransactions context here.
I don't quite understand how we can get possible leak here. If nobody holds the reference to TcpClientTransactions instance and nobody holds the reference to TcpClientTransaction instances, which were created by this TcpClientTransactions, the only references left outside of garbage objects it's a WeakReference to ThreadLocal from threads which have used this TcpClientTransactions instance. These weak references don't prevent to collect garbage objects.
Did I miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I got it. There is a weak reference only to ThreadLocal instance, but regular reference to TcpClientTransaction from the thread-local table, so memory leak is possible.
I will try to fix it tomorrow.

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've fixed the implementation. Also, I've found and fixed server-side transactions leak (transaction has left in active set after an attempt to end it when it's impossible to resume the transaction).

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@isapego isapego left a comment

Choose a reason for hiding this comment

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

Please see several minor comments.

import org.apache.ignite.internal.processors.platform.client.ClientResponse;

import java.util.LinkedHashMap;
import java.util.Map;
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and in other places, imports should not be re-ordered. See this page for details: https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines#CodingGuidelines-PackageImporting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was wrong formated before this patch: Import should be ordered alphabetically, but packages starting with 'java.' should be declared prior to others.
Now it exactly matches coding guidelines.

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.

4 participants