Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Added a note concerning the tearDown method #4953

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

Closed
wants to merge 1 commit into from

Conversation

Meyfarth
Copy link

@Meyfarth Meyfarth commented Feb 2, 2015

Added a hint to properly close the connection depending on the PHP version.

Added a hint to properly close the connection depending on the PHP version.
@timglabisch
Copy link
Contributor

this is not clear enough to me, we should provide a like to some kind of issue related to this.

@xabbuh
Copy link
Member

xabbuh commented Feb 2, 2015

I agree with @timglabisch.

@Meyfarth What are the conditions under which you to call the function and when do you have to do it? We should clarify them.

@Meyfarth
Copy link
Author

Meyfarth commented Feb 3, 2015

I had the problem on my server : when testing with phpunit, I ended up with a "Too many connections" error.
I found this page to solve the problem, but after implementing it, the problem was still there.
After some research, I found this solution and it worked like a charm.

Link : http://stackoverflow.com/a/26507379

@wouterj
Copy link
Member

wouterj commented Feb 4, 2015

For the SO question you linked to, it seems like closing the doctrine connection is better: http://stackoverflow.com/a/8518462/1149495

@Meyfarth
Copy link
Author

Meyfarth commented Feb 6, 2015

I saw that one too, and tried it before finding the "gc_collect_cycles()" solution, with the same result -> Too many connections.

@javiereguiluz
Copy link
Member

If I understand the linked answer correctly, they suggest to add both $entityManager->getConnection()->close(); and gc_collect_cycles().

Given that some people are suffering these problems (I suffered them myself too) I think we should make a last effort to finish and merge these changes. Thanks.

@stof
Copy link
Member

stof commented Jun 11, 2015

DoctrineBundle 1.4+ closes the connection already on shutdown. No need to do it manually in all your tests (and WebTestcase shutdowns the kernel on teardown)

@stof
Copy link
Member

stof commented Jun 11, 2015

btw, I don't see why gc_collect_cycles() might help here

@Meyfarth
Copy link
Author

That's the point : there is no logic on that, I just had to do it to make it work, and obviously I'm not the only one who had this problem.

@stof
Copy link
Member

stof commented Jun 11, 2015

btw, closing the entity manager is not necessary anymore either with DoctrineBundle 1.4+ as it also does it. So this article might be simplified.

@stof
Copy link
Member

stof commented Jun 11, 2015

Actually, I have an idea why gc_collect_cycle might have an influence. It will force the GC to run, meaning that the container being discarded during the shutdown will then be collected with all services in it, while relying on the refcount alone is not enough because of circular dependencies (see symfony/symfony#13448 for my proposal to help this). If the doctrine connection was GCed, it was of course closed at this time. And another case where it might be needed is for people using a PDO connection directly as they will stay connected until being destructed (either through refcount or GC).

@wouterj
Copy link
Member

wouterj commented Aug 22, 2015

So, now symfony/symfony#15185 is merged, is this note still needed /cc @stof ?

If so, can we - now we know why this might be needed - formalize a more explicit note (like "If you do/use XXX and get an 'too many connections' error in your tests, add gc_collect_cycles() to the tearDown of your test").

@OskarStark
Copy link
Contributor

@Meyfarth can you please answer to @wouterj comment?

@wouterj
Copy link
Member

wouterj commented Nov 8, 2015

@stof can you please tell me whether this is still relevant, now we have a resettable container in Symfony?

@wouterj
Copy link
Member

wouterj commented Feb 6, 2016

Closing because of the lack of response and because nobody else seems to have this issue. Feel free to comment, there is a reopen button in GitHub :)

@wouterj wouterj closed this Feb 6, 2016
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.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.