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

Procedures now close acquired KernelStatements #9764

Merged
merged 3 commits into from Aug 16, 2017

Conversation

burqen
Copy link
Contributor

@burqen burqen commented Aug 2, 2017

Verified in test by performing two index reads with
intermediate create. Second read should see result
of create but will not if KernelStatement has leaked,
because Lucene reader from first match will be reused
for second read.

Verified in test by performing two index reads with
intermediate create. Second read should see result
of create but will not if KernelStatement has leaked,
because Lucene reader from first match will be reused
for second read.
@burqen
Copy link
Contributor Author

burqen commented Aug 2, 2017

Iterator<RelationshipType> relationshipTypeIterator =
graphDatabaseAPI.getAllRelationshipTypesInUse().iterator();
while ( relationshipTypeIterator.hasNext() )
try ( Transaction transaction = graphDatabaseAPI.beginTx(); )
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this inner transaction? We are already in a transaction, so this will be a dummy.

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 would guess not, but cleaning this up is outside the scope of this PR.

Copy link
Contributor

@MishaDemianenko MishaDemianenko left a comment

Choose a reason for hiding this comment

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

Looks good, a couple of small comments. While this change cleaned up a lot of incorrect statements usages here and there I think we need more strict eyes on those. We need the tracker that will track open statements in the transaction and will fail it in the case when it will be closed without statements being closed across all our tests at least, sounds like a good idea?

RelationshipType relationshipType = relationshipTypeIterator.next();
String relationshipTypeGetName = relationshipType.name();
int relId = readOperations.relationshipTypeGetForName( relationshipTypeGetName );
ResourceIterator<Label> labelsInUse = graphDatabaseAPI.getAllLabelsInUse().iterator();
Copy link
Contributor

Choose a reason for hiding this comment

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

this resource iterator should be closed as well

}
try ( Transaction tx = db.beginTx() )
{
db.schema().awaitIndexesOnline( 1, TimeUnit.SECONDS );
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be not enough on latest 3.3 version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... set to 5 just in case then.


private String buildProcedureQuery( String procedureName, List<Object> parameters )
{
StringBuilder sb = new StringBuilder();
Copy link
Contributor

Choose a reason for hiding this comment

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

String joiner can be used here to simplify looping and checks, not that important in the same time

Copy link
Contributor

Choose a reason for hiding this comment

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

that is what i thinking about:

        StringJoiner stringJoiner = new StringJoiner( ",", "CALL " + procedureName + "(", ")" );
        for ( Object parameter : parameters )
        {
            stringJoiner.add( parameter.toString() );
        }
        return stringJoiner.toString();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aaah, cool!

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class ProcedureResourcesIT
Copy link
Contributor

Choose a reason for hiding this comment

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

different versions will contain different procedures so this test will need some adaptations during merges be careful there 👀

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class ProcedureResourcesIT
Copy link
Contributor

Choose a reason for hiding this comment

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

its' also strange that this test does not catch a case where we still have one statement that is not closed because of not closed resource iterable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Problem was there was no relationships in the dataset which meant that code path was never hit. Fixed now.

@burqen
Copy link
Contributor Author

burqen commented Aug 10, 2017

For completeness. Here is an attempt at tracking open statements: #9794

@burqen
Copy link
Contributor Author

burqen commented Aug 10, 2017

@MishaDemianenko Comments addressed. Will take care to adapt test during forward merge!

}
sb.append( joiner.toString() );
sb.append( ")" );
System.out.println( sb.toString() );
Copy link
Contributor

Choose a reason for hiding this comment

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

in any case you do not need to print this string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

*facepalm*

Copy link
Contributor

@MishaDemianenko MishaDemianenko left a comment

Choose a reason for hiding this comment

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

@burqen 2 small comments otherwise looks good will approve now but please take a look on them

@burqen
Copy link
Contributor Author

burqen commented Aug 15, 2017

@MishaDemianenko Ping 👍

@MishaDemianenko
Copy link
Contributor

@burqen Pong, whats up?)

@MishaDemianenko
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants