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

database: reduce pruneLocks/Unlock transaction. #6

Merged
merged 1 commit into from
Nov 16, 2015

Conversation

Quentin-M
Copy link
Contributor

pruneLocks could create deadlocked transactions on PostgreSQL if multiple locks expired and pruneLocks is called by multiple instances because Cayley does not guarantee the order.

InsertNotifications and InsertVulnerabilities also insert multiple independent items in a single same transaction. Doing so in InsertNotifications helps because as the transaction only contains new quads, COPY can be used. For the same reason, it could not create a deadlocked transaction. In the other hand, InsertVulnerabilities may delete some fields. However, just like InsertNotifications, it is called from the updater - which run only once per cluster: it could not create a deadlocked transaction. Additionally, the updater relies on the fact that these two functions will fail and rollback entirely if any of the elements can't be inserted (for any reason) - in which case it will not mark the update as done and will redo it later. I believe that because of the reasons above, they should not be modified.

@@ -68,7 +68,6 @@ func Lock(name string, duration time.Duration, owner string) (bool, time.Time) {
func Unlock(name, owner string) {
pruneLocks()

t := cayley.NewTransaction()
it, _ := cayley.StartPath(store, name).Has("locked", "locked").Has("locked_by", owner).Save("locked_until", "locked_until").BuildIterator().Optimize()
Copy link

Choose a reason for hiding this comment

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

If the assumption is that this will only return one thing from the iterator, please verify it and log an error if your assumption is violated. The change to the transaction scope should be fine.

pruneLocks could create deadlocked transactions on PostgreSQL if multiple locks expired and pruneLocks is called by multiple instances. Also adds some logging.
@jakedt
Copy link

jakedt commented Nov 16, 2015

LGTM

Quentin-M pushed a commit that referenced this pull request Nov 16, 2015
database: reduce pruneLocks/Unlock transaction.
@Quentin-M Quentin-M merged commit 9a3bea8 into quay:master Nov 16, 2015
@Quentin-M Quentin-M deleted the reduce_tx branch November 16, 2015 18:20
Quentin-M pushed a commit that referenced this pull request Feb 24, 2016
api: adjust postLayer error codes
@jzelinskie jzelinskie added kind/bug things are not as they seem reviewed/lgtm labels Mar 12, 2016
Allda added a commit to Allda/clair that referenced this pull request Apr 23, 2019
Filter out duplicated RPMs in higher layers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug things are not as they seem
Development

Successfully merging this pull request may close these issues.

None yet

3 participants