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

[TransactionalLevelDB] Fix iterating 'Prev' from evicted iterators #20182

Merged
merged 1 commit into from Nov 8, 2019

Conversation

@chromium-wpt-export-bot
Copy link
Collaborator

chromium-wpt-export-bot commented Nov 8, 2019

Iterators in TransactionalLevelDB are evicted when there are any
changes to the database. There is an edge case where an iterator is
evicted while on the 'last' key of the database, and that key is
deleted. When reloaded, it Seek()s to the previous key, only to
become 'Invalid' because it reaches the end of the database.
Unfortunately leveldb doesn't allow 'Prev' to be called from the end
of the database and instead just stays invalid.

The fix checks for the state where 'the iterator was valid before
eviction and is invalid after reloading' in the Prev() method. In
this state, there must be no no keys at or after the previously
loaded key. Thus calling SeekToLast() will correctly position the
iterator at the first element 'Prev' the previously loaded key.

Bug: 1022594
Change-Id: Ifa938b441683ea9f2cac5d926ff22b734ab4bb67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1897007
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Auto-Submit: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#713947}

Copy link
Collaborator

wpt-pr-bot left a comment

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot changed the title [IndexedDB] Testing iteration order differences with index [TransactionalLevelDB] Fix iterating 'Prev' from evicted iterators Nov 8, 2019
@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-1897007 branch from a9996ad to 9598b3d Nov 8, 2019
Iterators in TransactionalLevelDB are evicted when there are any
changes to the database. There is an edge case where an iterator is
evicted while on the 'last' key of the database, and that key is
deleted. When reloaded, it Seek()s to the previous key, only to
become 'Invalid' because it reaches the end of the database.
Unfortunately leveldb doesn't allow 'Prev' to be called from the end
of the database and instead just stays invalid.

The fix checks for the state where 'the iterator was valid before
eviction and is invalid after reloading' in the Prev() method. In
this state, there must be no no keys at or after the previously
loaded key. Thus calling SeekToLast() will correctly position the
iterator at the first element 'Prev' the previously loaded key.

Bug: 1022594
Change-Id: Ifa938b441683ea9f2cac5d926ff22b734ab4bb67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1897007
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Auto-Submit: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#713947}
@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-1897007 branch from 9598b3d to 647f6e1 Nov 8, 2019
@chromium-wpt-export-bot chromium-wpt-export-bot merged commit bee0426 into master Nov 8, 2019
12 checks passed
12 checks passed
Azure Pipelines Build #20191108.68 succeeded
Details
Azure Pipelines (./wpt test-jobs) ./wpt test-jobs succeeded
Details
Azure Pipelines (affected tests without changes: Safari Technology Preview) affected tests without changes: Safari Technology Preview succeeded
Details
Azure Pipelines (affected tests: Safari Technology Preview) affected tests: Safari Technology Preview succeeded
Details
Azure Pipelines (wpt.fyi hook: safari-preview-affected-tests) wpt.fyi hook: safari-preview-affected-tests succeeded
Details
Azure Pipelines (wpt.fyi hook: safari-preview-affected-tests-without-changes) wpt.fyi hook: safari-preview-affected-tests-without-changes succeeded
Details
Community-TC (pull_request) TaskGroup: success
Details
staging.wpt.fyi - chrome[experimental] Chrome results
Details
staging.wpt.fyi - firefox[experimental] Firefox results
Details
wpt.fyi - chrome[experimental] Chrome results
Details
wpt.fyi - firefox[experimental] Firefox results
Details
wpt.fyi - safari[experimental] Safari results
Details
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-1897007 branch Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.