Skip to content

Fixed #1033 - Requests pending with POST _bulk_docs#1034

Merged
zgramana merged 1 commit intomasterfrom
feature/issue_1033_Router_bulk_docs_hang
Feb 14, 2016
Merged

Fixed #1033 - Requests pending with POST _bulk_docs#1034
zgramana merged 1 commit intomasterfrom
feature/issue_1033_Router_bulk_docs_hang

Conversation

@hideki
Copy link
Copy Markdown

@hideki hideki commented Feb 14, 2016

Problem:
  • _bulk_docs: Calling synchronized(db) in transaction wait for db lock with holding SQLite connection
  • other request: waiting for SQLConnection with holding db lock.
Solution:

Router.java:

  • Eliminate all synchronized block from Router as most of database access are protected by Transaction.
  • Use runInTransaction for putLocalRevision() which is not inTransaction

Database.java:

  • make compact() thread-safe

Concern:

  • Database.delete() and Database.close()'s thread-safety. Need to review later.

##### Problem:
- _bulk_docs: Calling synchronized(db) in transaction wait for db lock with holding SQLite connection
- other request: waiting for SQLConnection with holding db lock.

##### Solution:
Router.java:
- Eliminate all synchronized block from Router as most of database access are protected by Transaction.
- Use runInTransaction for putLocalRevision() which is not inTransaction

Database.java:
- make compact() thread-safe

Concern:
- Database.delete() and Database.close()'s thread-safety. Need to review later.
zgramana added a commit that referenced this pull request Feb 14, 2016
…k_docs_hang

Fixed #1033 - Requests pending with POST _bulk_docs
@zgramana zgramana merged commit 6db0e99 into master Feb 14, 2016
@hideki hideki deleted the feature/issue_1033_Router_bulk_docs_hang branch February 14, 2016 23:00
store.compact();
synchronized (store) {
store.compact();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is nothing wrong with this synchronized. I checked the Database.java code and found that some code path does synchronized (store) but some not. If the intension to make Database thread safe, all of those synchronized (store) and not synchronized (store) should be revised.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have same concern. I would like to fix this issue with new ticket. https://github.com/couchbase/couchbase-lite-java-core/issues/1035

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.

3 participants