1
0
Fork 0
This commit is contained in:
Jan 2018-01-25 15:57:13 +01:00 committed by GitHub
parent fe0fca9029
commit caf409b638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 4 deletions

View File

@ -7,6 +7,8 @@ devel
superseded by other REST APIs and were partially dysfunctional. Therefore
these two endpoints have been removed entirely.
* fix issue #4272: VERSION file keeps disappearing
* fix internal issue #81: quotation marks disappeared when switching table/json
editor in the query editor ui

View File

@ -33,10 +33,13 @@
#include "Basics/tri-strings.h"
#include "MMFiles/MMFilesCollection.h"
#include "MMFiles/MMFilesDatafileHelper.h"
#include "MMFiles/MMFilesEngine.h"
#include "MMFiles/MMFilesLogfileManager.h"
#include "MMFiles/MMFilesPersistentIndexFeature.h"
#include "MMFiles/MMFilesWalSlots.h"
#include "Rest/Version.h"
#include "RestServer/DatabaseFeature.h"
#include "StorageEngine/EngineSelectorFeature.h"
#include "Transaction/Helpers.h"
#include "Transaction/Hints.h"
#include "Transaction/StandaloneContext.h"
@ -1267,12 +1270,16 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
std::string nameString = nameSlice.copyString();
MMFilesEngine* engine = static_cast<MMFilesEngine*>(EngineSelectorFeature::ENGINE);
std::string const versionFile = engine->versionFilename(databaseId);
std::string const versionFileContent = std::string("{\"version\":") + std::to_string(rest::Version::getNumericServerVersion()) + ",\"tasks\":{}}";
// remove already existing database with same name
vocbase = state->databaseFeature->lookupDatabase(nameString);
if (vocbase != nullptr) {
TRI_voc_tick_t otherId = vocbase->id();
state->releaseDatabase(otherId);
// TODO: how to signal a dropDatabase failure here?
state->databaseFeature->dropDatabase(nameString, true, false);
@ -1292,6 +1299,15 @@ bool MMFilesWalRecoverState::ReplayMarker(MMFilesMarker const* marker,
return state->canContinue();
}
try {
basics::FileUtils::spit(versionFile, versionFileContent);
} catch (...) {
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "unable to store version file '" << versionFile << "' for database "
<< databaseId;
++state->errorCount;
return state->canContinue();
}
break;
}

View File

@ -25,6 +25,7 @@
#include "Agency/AgencyComm.h"
#include "Basics/StringUtils.h"
#include "Basics/VelocyPackHelper.h"
#include "Cluster/ClusterInfo.h"
#include "Cluster/ServerState.h"
#include "GeneralServer/AuthenticationFeature.h"
@ -152,13 +153,13 @@ arangodb::Result Databases::create(std::string const& dbName,
if (options.isNone() || options.isNull()) {
options = VPackSlice::emptyObjectSlice();
} else if (!options.isObject()) {
return Result(TRI_ERROR_HTTP_BAD_PARAMETER);
return Result(TRI_ERROR_HTTP_BAD_PARAMETER, "invalid options slice");
}
VPackSlice users = inUsers;
if (users.isNone() || users.isNull()) {
users = VPackSlice::emptyArraySlice();
} else if (!users.isArray()) {
return Result(TRI_ERROR_HTTP_BAD_PARAMETER);
return Result(TRI_ERROR_HTTP_BAD_PARAMETER, "invalid users slice");
}
VPackBuilder sanitizedUsers;
@ -298,7 +299,7 @@ arangodb::Result Databases::create(std::string const& dbName,
// purposes)
TRI_voc_tick_t id = 0;
if (options.hasKey("id")) {
id = options.get("id").getUInt();
id = basics::VelocyPackHelper::stringUInt64(options, "id");
}
TRI_vocbase_t* vocbase = nullptr;
@ -320,6 +321,8 @@ arangodb::Result Databases::create(std::string const& dbName,
});
}
TRI_ASSERT(V8DealerFeature::DEALER != nullptr);
V8Context* ctx = V8DealerFeature::DEALER->enterContext(vocbase, true);
if (ctx == nullptr) {
return Result(TRI_ERROR_INTERNAL, "Could not get v8 context");

View File

@ -0,0 +1,81 @@
/* jshint globalstrict:false, strict:false, unused : false */
/* global assertNotEqual */
// //////////////////////////////////////////////////////////////////////////////
// / @brief tests for transactions
// /
// / @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 2013, triAGENS GmbH, Cologne, Germany
// //////////////////////////////////////////////////////////////////////////////
var db = require('@arangodb').db;
var internal = require('internal');
var jsunity = require('jsunity');
function runSetup () {
'use strict';
internal.debugClearFailAt();
db._createDatabase('UnitTestsRecovery');
db._useDatabase('UnitTestsRecovery');
require("fs").remove(db._versionFilename());
internal.debugSegfault('crashing server');
}
// //////////////////////////////////////////////////////////////////////////////
// / @brief test suite
// //////////////////////////////////////////////////////////////////////////////
function recoverySuite () {
'use strict';
jsunity.jsUnity.attachAssertions();
return {
setUp: function () {},
tearDown: function () {},
// //////////////////////////////////////////////////////////////////////////////
// / @brief test whether we the data are correct after restart
// //////////////////////////////////////////////////////////////////////////////
testCreateDatabaseRecovery: function () {
assertNotEqual(-1, db._databases().indexOf('UnitTestsRecovery'));
db._useDatabase('UnitTestsRecovery');
}
};
}
// //////////////////////////////////////////////////////////////////////////////
// / @brief executes the test suite
// //////////////////////////////////////////////////////////////////////////////
function main (argv) {
'use strict';
if (argv[1] === 'setup') {
runSetup();
return 0;
} else {
jsunity.run(recoverySuite);
return jsunity.done().status ? 0 : 1;
}
}