-
Notifications
You must be signed in to change notification settings - Fork 857
Rdb index background (preliminary) #7644
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
3f6967c
Initial commit
graetzer 38b3500
make sure index is hidden
graetzer 0ddb321
Merge branch 'devel' of github.com:arangodb/arangodb into feature/rdb…
graetzer 9bcc737
last changes
graetzer c57de4f
fix a bug
graetzer c798357
reduce conflicts
graetzer 4766900
fix background indexing
graetzer b525712
remove unused code
graetzer 0515650
fix link creation
graetzer 70ef2f1
fix unique constraint violations
graetzer e6d23c1
fixed arangosearch cluster reporting
graetzer 13bcd44
added test
graetzer 9e5f960
fix test
graetzer 6bfd840
make noncluster for now
graetzer 3d20521
fix jslint
graetzer 38005e0
Some test adjustments.
dc041fb
Merge branch 'devel' into feature/rdb-index-background
a7ae28a
Fix merge error.
db46a40
changes
graetzer 9db5709
Merge branch '
8000
feature/rdb-index-background' of github.com:arangodb/ar…
graetzer ef4bb05
adding inBackground flag
graetzer 5546745
Merge branch 'devel' into feature/rdb-index-background
2ebf591
Fix merge errors.
2082f78
adding some docs
graetzer 3efc632
Merge branch 'devel' into feature/rdb-index-background
98ddd16
Some small changes.
ee51fa5
Fixed removal bug and added test.
422e0ce
Added update test.
31d9d7b
Merge branch 'devel' of github.com:arangodb/arangodb into feature/rdb…
graetzer a34f928
forgot to comment out docs
graetzer 021453c
fixing some code
graetzer f61b5e9
fix jslint
graetzer b013b15
remove some code
graetzer 82f4b6e
fix reporting of unfinished indexes
graetzer b7d6a9d
Merge branch 'devel' of github.com:arangodb/arangodb into feature/rdb…
graetzer 2f1cc80
fixing fillIndex for iresearch
graetzer 371c738
revert a change
graetzer 7f4e2e7
Merge branch 'devel' of github.com:arangodb/arangodb into feature/rdb…
graetzer 3f46816
fixng a deadlock
graetzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
changes
- Loading branch information
commit db46a40334f50b706f1510f21cd37230b96c7a4a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,30 +71,19 @@ Result RocksDBBuilderIndex::insertInternal(transaction::Methods* trx, RocksDBMet | |
arangodb::velocypack::Slice const& slice, | ||
OperationMode mode) { | ||
Result r = _wrapped->insertInternal(trx, mthd, documentId, slice, mode); | ||
if (!r.ok() && !_hasError.load(std::memory_order_acquire)) { | ||
_errorResult = r; | ||
_hasError.store(true, std::memory_order_release); | ||
if (r.is(TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED) || | ||
r.is(TRI_ERROR_LOCK_TIMEOUT) || | ||
r.is(TRI_ERROR_DEADLOCK) || | ||
r.is(TRI_ERROR_ARANGO_CONFLICT)) { | ||
bool expected = false; | ||
if (!r.ok() && !_hasError.compare_exchange_strong(expected, true, std::memory_order_release)) { | ||
std::lock_guard<std::mutex> guard(_errorMutex); | ||
_errorResult = r; | ||
} | ||
} | ||
return Result(); | ||
} | ||
|
||
//Result RocksDBBuilderIndex::updateInternal(transaction::Methods* trx, RocksDBMethods* mthd, | ||
// LocalDocumentId const& oldDocumentId, | ||
// arangodb::velocypack::Slice const& oldDoc, | ||
// LocalDocumentId const& newDocumentId, | ||
// arangodb::velocypack::Slice const& newDoc, | ||
// OperationMode mode) { | ||
// // It is illegal to call this method on the primary index | ||
// // RocksDBPrimaryIndex must override this method accordingly | ||
// TRI_ASSERT(type() != TRI_IDX_TYPE_PRIMARY_INDEX); | ||
// | ||
// Result res = removeInternal(trx, mthd, oldDocumentId, oldDoc, mode); | ||
// if (!res.ok()) { | ||
// return res; | ||
// } | ||
// return insertInternal(trx, mthd, newDocumentId, newDoc, mode); | ||
//} | ||
|
||
/// remove index elements and put it in the specified write batch. | ||
Result RocksDBBuilderIndex::removeInternal(transaction::Methods* trx, RocksDBMethods* mthd, | ||
LocalDocumentId const& documentId, | ||
|
@@ -112,9 +101,15 @@ Result RocksDBBuilderIndex::removeInternal(transaction::Methods* trx, RocksDBMet | |
} | ||
|
||
Result r = _wrapped->removeInternal(trx, mthd, documentId, slice, mode); | ||
if (!r.ok() && !_hasError.load(std::memory_order_acquire)) { | ||
_errorResult = r; | ||
_hasError.store(true, std::memory_order_release); | ||
if (r.is(TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED) || | ||
r.is(TRI_ERROR_LOCK_TIMEOUT) || | ||
r.is(TRI_ERROR_DEADLOCK) || | ||
r.is(TRI_ERROR_ARANGO_CONFLICT)) { | ||
bool expected = false; | ||
if (!r.ok() && !_hasError.compare_exchange_strong(expected, true, std::memory_order_release)) { | ||
std::lock_guard<std::mutex> guard(_errorMutex); | ||
_errorResult = r; | ||
} | ||
} | ||
return Result(); | ||
} | ||
|
@@ -128,6 +123,12 @@ arangodb::Result RocksDBBuilderIndex::fillIndexBackground(std::function<void()> | |
// 3. Avoid conflicts on unique index keys by using rocksdb::Transaction snapshot conflict checking | ||
// 4. Supress unique constraint violations / conflicts or client drivers | ||
|
||
auto lockedDocsGuard = scopeGuard([&] { // clear all the processed documents | ||
std::lock_guard<std::mutex> guard(_lockedDocsMutex); | ||
_lockedDocs.clear(); | ||
_lockedDocsCond.notify_all(); | ||
}); | ||
|
||
// fillindex can be non transactional, we just need to clean up | ||
RocksDBEngine* engine = rocksutils::globalRocksEngine(); | ||
RocksDBCollection* rcoll = static_cast<RocksDBCollection*>(_collection.getPhysical()); | ||
|
@@ -177,7 +178,7 @@ arangodb::Result RocksDBBuilderIndex::fillIndexBackground(std::function<void()> | |
} else { | ||
rtrx->DisableIndexing(); // we never check for existing index keys | ||
} | ||
RocksDBSubTrxMethods batched(state, rtrx.get()); | ||
RocksDBSideTrxMethods batched(state, rtrx.get()); | ||
|
||
RocksDBIndex* internal = _wrapped.get(); | ||
TRI_ASSERT(internal != nullptr); | ||
|
@@ -186,6 +187,7 @@ arangodb::Result RocksDBBuilderIndex::fillIndexBackground(std::function<void()> | |
while (it->Valid() && it->key().compare(upper) < 0) { | ||
|
||
if (_hasError.load(std::memory_order_acquire)) { | ||
std::lock_guard<std::mutex> guard(_errorMutex); | ||
res = _errorResult; // a Writer got an error | ||
break; | ||
} | ||
|
@@ -197,7 +199,7 @@ arangodb::Result RocksDBBuilderIndex::fillIndexBackground(std::function<void()> | |
continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be able to remove it from the set here, right? We won't encounter the same revision again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes but lets avoid re-hashing it |
||
} | ||
std::lock_guard<std::mutex> guard2(_lockedDocsMutex); | ||
_lockedDocs.insert(docId.id());// must be done under _removedDocsMutex | ||
_lockedDocs.insert(docId.id()); | ||
} | ||
|
||
res = internal->insertInternal(&trx, &batched, docId, | ||
|
@@ -215,7 +217,7 @@ arangodb::Result RocksDBBuilderIndex::fillIndexBackground(std::function<void()> | |
break; | ||
} | ||
{ // clear all the processed documents | ||
std::lock_guard<std::mutex> guard2(_lockedDocsMutex); | ||
std::lock_guard<std::mutex> guard(_lockedDocsMutex); | ||
_lockedDocs.clear(); | ||
_lockedDocsCond.notify_all(); | ||
} | ||
|
@@ -240,11 +242,6 @@ arangodb::Result RocksDBBuilderIndex::fillIndexBackground(std::function<void()> | |
res = trx.commit(); // required to commit selectivity estimates | ||
} | ||
|
||
// clear all the processed documents | ||
std::lock_guard<std::mutex> guard2(_lockedDocsMutex); | ||
_lockedDocs.clear(); | ||
_lockedDocsCond.notify_all(); | ||
|
||
return res; | ||
} | ||
|
||
|
@@ -331,15 +328,12 @@ static arangodb::Result fillIndexFast(transaction::Methods& trx, | |
|
||
/// non-transactional: fill index with existing documents | ||
/// from this collection | ||
arangodb::Result RocksDBBuilderIndex::fillIndex(std::function<void()> const& unlock) { | ||
// TRI_ASSERT(trx.state()->collection(_collection.id(), AccessMode::Type::WRITE)); | ||
arangodb::Result RocksDBBuilderIndex::fillIndexFast() { | ||
|
||
#if 0 | ||
RocksDBCollection* coll = static_cast<RocksDBCollection*>(_collection.getPhysical()); | ||
unlock(); // we do not need the outer lock | ||
SingleCollectionTransaction trx(transaction::StandaloneContext::Create(_collection.vocbase()), | ||
_collection, AccessMode::Type::EXCLUSIVE); | ||
res = trx.begin(); | ||
Result res = trx.begin(); | ||
if (!res.ok()) { | ||
THROW_ARANGO_EXCEPTION(res); | ||
} | ||
|
@@ -355,6 +349,4 @@ arangodb::Result RocksDBBuilderIndex::fillIndex(std::function<void()> const& unl | |
rocksdb::WriteBatch batch(32 * 1024 * 1024); | ||
return ::fillIndexFast<rocksdb::WriteBatch, RocksDBBatchedMethods>(trx, this, coll, batch); | ||
} | ||
#endif | ||
return fillIndexBackground(unlock); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.