elixir-ecto / db_connection

Database connection behaviour
http://hexdocs.pm/db_connection/DBConnection.html
309 stars 112 forks source link

Smarter hibernate #103

Closed redink closed 6 years ago

redink commented 6 years ago

from #101

redink commented 6 years ago

I added a way for test the hibernate, I have no idea but only this one.

If you have better one, give me help please. Thanks.

fishcakez commented 6 years ago

@redink we could read the memory in the callback and send it in the message to the test process and then in a recursive loop wait for it to go down. Alternatively in a similar recursive loop we could wait for the Process.info(self(), current_function) to change to the appropriate function.

We should consider limiting the loop by a time limit using System.monotonic_time. Also we could sleep between each check to allow other processes to run.

fishcakez commented 6 years ago

@redink I left some comments: the main takeaway is that the timer is for idling and for hibernating. The hibernation occurs after the idle handling (calling the ping callback), and it is possible we won't hibernate. The new option is to go idle after we ping or after we fail to connect.

redink commented 6 years ago

sojourn test still have problem, I will work on it later.

fishcakez commented 6 years ago

@redink the last changes look good. It might be that Sojourn doesn't play well with hibernate because of how the pool works. I suggest we don't implement hibernate for it yet and add the @idle_hibernate tag for sojourn tests.

redink commented 6 years ago

Hello, Any updates ? Or any more comments ?

fishcakez commented 6 years ago

@redink there is a performance regression so need to look in it.

fishcakez commented 6 years ago

Closing in favor of #108.