-
Notifications
You must be signed in to change notification settings - Fork 856
Bug fix/dont use indexes in progress #10432
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b6d715f
don't return any in-progress indexes
jsteemann 3f32892
fix handling of in-progress indexes
jsteemann 17dddd9
add test
jsteemann 3776c6f
Merge branch 'devel' of github.com:arangodb/arangodb into bug-fix/don…
jsteemann aa2df9a
address review comments
jsteemann 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/*jshint globalstrict:false, strict:false */ | ||
/*global assertEqual, assertNotEqual, assertTrue */ | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
/// @brief test index usage | ||
/// | ||
/// @file | ||
/// | ||
/// DISCLAIMER | ||
/// | ||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany | ||
/// | ||
/// Licensed under the Apache License, Version 2.0 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// http://www.apache.org/licenses/LICENSE-2.0 | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
/// | ||
/// Copyright holder is triAGENS GmbH, Cologne, Germany | ||
/// | ||
/// @author Jan Steemann | ||
/// @author Copyright 2018, triAGENS GmbH, Cologne, Germany | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
let jsunity = require("jsunity"); | ||
|
||
let arangodb = require("@arangodb"); | ||
let db = arangodb.db; | ||
let tasks = require("@arangodb/tasks"); | ||
|
||
function IndexUsageSuite () { | ||
const cnData = "UnitTestsCollection"; // used for test data | ||
const cnComm = "UnitTestsCommunication"; // used for communication | ||
|
||
return { | ||
|
||
setUp : function () { | ||
db._drop(cnData); | ||
db._drop(cnComm); | ||
db._create(cnData); | ||
db._create(cnComm); | ||
|
||
let docs = []; | ||
for (let i = 0; i < 5000; ++i) { | ||
docs.push({ value: "test" + i }); | ||
} | ||
db[cnData].insert(docs); | ||
}, | ||
|
||
tearDown : function () { | ||
db._drop(cnData); | ||
db._drop(cnComm); | ||
}, | ||
|
||
testIndexUsage : function () { | ||
let task = tasks.register({ | ||
command: function(params) { | ||
require('jsunity').jsUnity.attachAssertions(); | ||
let db = require("internal").db; | ||
let comm = db[params.cnComm]; | ||
let errors = require("@arangodb").errors; | ||
comm.insert({ _key: "runner1", value: 0 }); | ||
|
||
while (!comm.exists("runner2")) { | ||
require("internal").sleep(0.02); | ||
} | ||
|
||
let success = 0; | ||
let time = require("internal").time; | ||
let start = time(); | ||
do { | ||
try { | ||
db._query("FOR doc IN " + params.cnData + " FILTER doc.value > 10 LIMIT 10 RETURN doc"); | ||
comm.update("runner1", { value: ++success }); | ||
} catch (err) { | ||
// if the index that was picked for the query is dropped in the meantime, | ||
// we will get the following error back | ||
assertEqual(err.errorNum, errors.ERROR_QUERY_BAD_JSON_PLAN.code); | ||
} | ||
} while (time() - start < 10.0); | ||
}, | ||
params: { cnComm, cnData } | ||
}); | ||
|
||
let comm = db[cnComm]; | ||
comm.insert({ _key: "runner2" }); | ||
while (!comm.exists("runner1")) { | ||
require("internal").sleep(0.02); | ||
} | ||
|
||
let time = require("internal").time; | ||
let start = time(); | ||
let success = 0; | ||
do { | ||
let indexes = db[cnData].indexes(); | ||
if (indexes.length > 1) { | ||
db[cnData].dropIndex(indexes[1]); | ||
} | ||
db[cnData].ensureIndex({ type: "hash", fields: ["value"], inBackground: true }); | ||
++success; | ||
} while (time() - start < 10.0); | ||
|
||
while (true) { | ||
try { | ||
tasks.get(task); | ||
require("internal").wait(0.25, false); | ||
} catch (err) { | ||
// "task not found" means the task is finished | ||
break; | ||
} | ||
} | ||
|
||
assertEqual(2, comm.count()); | ||
let doc = comm.document("runner1"); | ||
assertTrue(doc.value > 0, doc); | ||
assertTrue(success > 0, success); | ||
}, | ||
|
||
}; | ||
} | ||
|
||
jsunity.run(IndexUsageSuite); | ||
|
||
return jsunity.done(); |
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.