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

server: delay transact commit #199

Merged
merged 1 commit into from
Jul 26, 2021
Merged

Conversation

dave-tucker
Copy link
Collaborator

Changes shouldn't be made to the db unless the we know the whole
transaction will succeed.

This commit changes the Database interface so table indexes can be checked before a transaction is committed.
Once a transaciton is complete, it is commited to the database. This more closely mirrors how the real ovsdb-server works.

In order for this to work, we needed a IndexExists function in the cache.

Fixes: #196

@coveralls
Copy link

coveralls commented Jul 15, 2021

Pull Request Test Coverage Report for Build 1067601089

  • 208 of 453 (45.92%) changed or added relevant lines in 7 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-1.4%) to 75.742%

Changes Missing Coverage Covered Lines Changed/Added Lines %
server/mutate.go 6 7 85.71%
server/server.go 11 13 84.62%
server/database.go 22 26 84.62%
cache/cache.go 7 88 7.95%
server/transact.go 149 306 48.69%
Files with Coverage Reduction New Missed Lines %
server/database.go 3 79.31%
Totals Coverage Status
Change from base Build 1056314106: -1.4%
Covered Lines: 3216
Relevant Lines: 4246

💛 - Coveralls

Changes shouldn't be made to the db unless the we know the whole
transaction will succeed.

This commit changes the Database interface so table indexes can be checked before a transaction is committed.
Once a transaciton is complete, it is commited to the database. This more closely mirrors how the real ovsdb-server works.

In order for this to work, we needed a IndexExists function in the cache.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
}
db.mutex.RLock()
targetDb := db.databases[database]
db.mutex.RLock()
Copy link
Contributor

Choose a reason for hiding this comment

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

hi @dave-tucker . I am a little confused about the double db.mutex.RLock() call.
I see it in a couple of places in this file. Were they meant to be an unlock like
defer db.mutex.RUnlock() or a simple db.mutex.RUnlock() ?

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

Successfully merging this pull request may close these issues.

server: Implement Proper Transaction Handling
3 participants