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

Fix timeout on heartbeat with PostgreSQL (fixes #804) #809

Merged
merged 5 commits into from
Sep 12, 2016

Conversation

leplatrem
Copy link
Contributor

@leplatrem leplatrem commented Sep 7, 2016

I could see in PostgreSQL logs that heartbeat operations were starting a transaction without closing them (either commit/rollback), leading into errors like:

process 14701 still waiting for ShareLock on transaction 3024907 after 1000.114 ms

I could see in PostgreSQL logs that heartbeat operations were starting a transaction without closing them (either commit/rollback), leading into errors like:
```
process 14701 still waiting for ShareLock on transaction 3024907 after 1000.114 ms
```
@@ -92,5 +94,7 @@ def ping(request):
except:
logger.exception("Heartbeat Failure")
return False
finally:
transaction.abort()
Copy link
Member

Choose a reason for hiding this comment

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

Don't you want to commit rather than abort?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not... it will leave a useless trace in the DB, but we delete it on each call anyway.
Your call!

@leplatrem
Copy link
Contributor Author

@Natim @tarekziade r?

@@ -17,6 +19,8 @@ def get_heartbeat(request):
def heartbeat_check(name, func):
status[name] = False
status[name] = func(request)
# Rollback any open transaction (will release table locks etc.)
transaction.abort()
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want to do that at a upper level? I mean make sure the transaction have been canceled or committed each time a response have been sent?

# Since the heartbeat checks run concurrently, their transactions
# overlap and might end in shared lock errors. By aborting here
# we clean-up the state on each heartbeat call instead of once at the
# end of the request. See bug Kinto/kinto#804
transaction.abort()
Copy link
Member

Choose a reason for hiding this comment

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

Any idea why we abort rather than committing?

Copy link
Contributor Author

@leplatrem leplatrem Sep 12, 2016

Choose a reason for hiding this comment

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

The commit would have the same result (ie. ending the transaction), except that something would be left in the database between two calls.

Would you prefer ?

Copy link
Member

Choose a reason for hiding this comment

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

Yes i guess it makes sense to make sure the database is writable.

@Natim
Copy link
Member

Natim commented Sep 12, 2016

r+

@Natim Natim merged commit 8e4cd13 into master Sep 12, 2016
@Natim Natim removed the in progress label Sep 12, 2016
@Natim Natim deleted the 804-close-hearbeat-transactions branch September 12, 2016 11:20
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.

2 participants