mirror of https://gitee.com/bigwinds/arangodb
do not access shaper but use memory zone variable
This commit is contained in:
parent
cfa6f98a01
commit
f69ae8f2a9
|
@ -266,6 +266,7 @@ int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollecti
|
|||
assert(json != 0);
|
||||
|
||||
TRI_primary_collection_t* primary = trxCollection->_collection->_collection;
|
||||
TRI_memory_zone_t* zone = primary->_shaper->_memoryZone;
|
||||
TRI_shaped_json_t* shaped = TRI_ShapedJsonJson(primary->_shaper, json);
|
||||
|
||||
if (shaped != 0) {
|
||||
|
@ -320,7 +321,7 @@ int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollecti
|
|||
res = primary->update(trxCollection, key, rid, &mptr, shaped, &_policy, false, false);
|
||||
}
|
||||
|
||||
TRI_FreeShapedJson(primary->_shaper->_memoryZone, shaped);
|
||||
TRI_FreeShapedJson(zone, shaped);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1872,6 +1872,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
|
|||
assert(json != 0);
|
||||
|
||||
TRI_primary_collection_t* primary = trxCollection->_collection->_collection;
|
||||
TRI_memory_zone_t* zone = primary->_shaper->_memoryZone;
|
||||
TRI_shaped_json_t* shaped = TRI_ShapedJsonJson(primary->_shaper, json);
|
||||
|
||||
if (shaped != 0) {
|
||||
|
@ -1929,7 +1930,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
|
|||
res = primary->update(trxCollection, key, rid, &mptr, shaped, &policy, false, false);
|
||||
}
|
||||
|
||||
TRI_FreeShapedJson(primary->_shaper->_memoryZone, shaped);
|
||||
TRI_FreeShapedJson(zone, shaped);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -804,6 +804,7 @@ namespace triagens {
|
|||
}
|
||||
|
||||
TRI_shaper_t* shaper = this->shaper(trxCollection);
|
||||
TRI_memory_zone_t* zone = shaper->_memoryZone;
|
||||
TRI_shaped_json_t* shaped = TRI_ShapedJsonJson(shaper, json);
|
||||
|
||||
if (shaped == 0) {
|
||||
|
@ -819,7 +820,7 @@ namespace triagens {
|
|||
data,
|
||||
forceSync);
|
||||
|
||||
TRI_FreeShapedJson(shaper->_memoryZone, shaped);
|
||||
TRI_FreeShapedJson(zone, shaped);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -867,6 +868,7 @@ namespace triagens {
|
|||
const bool forceSync) {
|
||||
|
||||
TRI_shaper_t* shaper = this->shaper(trxCollection);
|
||||
TRI_memory_zone_t* zone = shaper->_memoryZone;
|
||||
TRI_shaped_json_t* shaped = TRI_ShapedJsonJson(shaper, json);
|
||||
|
||||
if (shaped == 0) {
|
||||
|
@ -883,7 +885,7 @@ namespace triagens {
|
|||
actualRevision,
|
||||
forceSync);
|
||||
|
||||
TRI_FreeShapedJson(shaper->_memoryZone, shaped);
|
||||
TRI_FreeShapedJson(zone, shaped);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -933,7 +933,7 @@ static bool IterateFiles (TRI_vector_string_t* vector,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializes a collection parameter block
|
||||
/// @brief initializes a collection parameters struct
|
||||
/// (options are added to the TRI_col_info_t* and have to be freed by the
|
||||
/// TRI_FreeCollectionInfoOptions() function)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1405,11 +1405,11 @@ int TRI_LoadCollectionInfo (char const* path,
|
|||
}
|
||||
|
||||
if (error != NULL) {
|
||||
LOG_ERROR("cannot open '%s', parameter block not readable: %s", filename, error);
|
||||
LOG_ERROR("cannot open '%s', collection parameters are not readable: %s", filename, error);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, error);
|
||||
}
|
||||
else {
|
||||
LOG_ERROR("cannot open '%s', parameter block not readable", filename);
|
||||
LOG_ERROR("cannot open '%s', collection parameters are not readable", filename);
|
||||
}
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, filename);
|
||||
|
||||
|
@ -1704,7 +1704,7 @@ TRI_collection_t* TRI_OpenCollection (TRI_vocbase_t* vocbase,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// read parameter block, no need to lock as we are opening the collection
|
||||
// read parameters, no need to lock as we are opening the collection
|
||||
res = TRI_LoadCollectionInfo(path, &info, true);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
|
@ -2135,7 +2135,8 @@ int TRI_UpgradeCollection15 (TRI_vocbase_t* vocbase,
|
|||
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
// TODO: fix the datafile id
|
||||
outfile = TRI_Concatenate2File(path, "datafile-1.db");
|
||||
|
||||
if (outfile == NULL) {
|
||||
|
@ -2157,7 +2158,7 @@ int TRI_UpgradeCollection15 (TRI_vocbase_t* vocbase,
|
|||
char const* file = files._buffer[i];
|
||||
|
||||
if (regexec(&re, file, sizeof(matches) / sizeof(matches[0]), matches, 0) == 0) {
|
||||
TRI_datafile_t* datafile;
|
||||
TRI_datafile_t* df;
|
||||
char* fqn;
|
||||
|
||||
fqn = TRI_Concatenate2File(shapes, file);
|
||||
|
@ -2209,9 +2210,9 @@ int TRI_UpgradeCollection15 (TRI_vocbase_t* vocbase,
|
|||
}
|
||||
|
||||
// open the datafile, and push it into a vector of datafiles
|
||||
datafile = TRI_OpenDatafile(fqn);
|
||||
df = TRI_OpenDatafile(fqn);
|
||||
|
||||
if (datafile == NULL) {
|
||||
if (df == NULL) {
|
||||
res = TRI_errno();
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, fqn);
|
||||
break;
|
||||
|
@ -2221,7 +2222,10 @@ int TRI_UpgradeCollection15 (TRI_vocbase_t* vocbase,
|
|||
si._fdout = fdout;
|
||||
si._written = &written;
|
||||
|
||||
TRI_IterateDatafile(datafile, UpgradeShapeIterator, &si, false, false);
|
||||
TRI_IterateDatafile(df, UpgradeShapeIterator, &si, false, false);
|
||||
|
||||
TRI_CloseDatafile(df);
|
||||
TRI_FreeDatafile(df);
|
||||
}
|
||||
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, fqn);
|
||||
|
@ -2251,6 +2255,17 @@ int TRI_UpgradeCollection15 (TRI_vocbase_t* vocbase,
|
|||
|
||||
TRI_DestroyVectorString(&files);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, outfile);
|
||||
|
||||
// try to remove SHAPES directory after upgrade
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
res = TRI_RemoveDirectory(shapes);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("unable to remove SHAPES directory '%s'",
|
||||
shapes);
|
||||
}
|
||||
}
|
||||
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, shapes);
|
||||
regfree(&re);
|
||||
|
||||
|
|
|
@ -431,6 +431,7 @@ static int LogEvent (TRI_replication_logger_t* logger,
|
|||
TRI_replication_operation_e type,
|
||||
TRI_string_buffer_t* buffer) {
|
||||
TRI_primary_collection_t* primary;
|
||||
TRI_memory_zone_t* zone;
|
||||
TRI_shaped_json_t* shaped;
|
||||
TRI_json_t json;
|
||||
TRI_doc_mptr_t mptr;
|
||||
|
@ -506,6 +507,7 @@ static int LogEvent (TRI_replication_logger_t* logger,
|
|||
TRI_BeginStringBuffer(buffer));
|
||||
|
||||
primary = logger->_trxCollection->_collection->_collection;
|
||||
zone = primary->_shaper->_memoryZone;
|
||||
shaped = TRI_ShapedJsonJson(primary->_shaper, &json);
|
||||
TRI_DestroyJson(TRI_CORE_MEM_ZONE, &json);
|
||||
|
||||
|
@ -525,7 +527,7 @@ static int LogEvent (TRI_replication_logger_t* logger,
|
|||
isStandaloneOperation,
|
||||
forceSync);
|
||||
|
||||
TRI_FreeShapedJson(primary->_shaper->_memoryZone, shaped);
|
||||
TRI_FreeShapedJson(zone, shaped);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
|
|
|
@ -620,7 +620,8 @@ static int CreateApplicationDirectory (char const* name,
|
|||
/// @brief iterate over all databases in the databases directory and open them
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int OpenDatabases (TRI_server_t* server) {
|
||||
static int OpenDatabases (TRI_server_t* server,
|
||||
bool isUpgrade) {
|
||||
TRI_vector_string_t files;
|
||||
size_t i, n;
|
||||
int res;
|
||||
|
@ -813,7 +814,13 @@ static int OpenDatabases (TRI_server_t* server) {
|
|||
// .............................................................................
|
||||
|
||||
// try to open this database
|
||||
vocbase = TRI_OpenVocBase(server, databaseDirectory, id, databaseName, &defaults, server->_wasShutdownCleanly);
|
||||
vocbase = TRI_OpenVocBase(server,
|
||||
databaseDirectory,
|
||||
id,
|
||||
databaseName,
|
||||
&defaults,
|
||||
isUpgrade,
|
||||
server->_wasShutdownCleanly);
|
||||
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, databaseName);
|
||||
|
||||
|
@ -1953,7 +1960,7 @@ int TRI_StartServer (TRI_server_t* server,
|
|||
// .............................................................................
|
||||
|
||||
// scan all databases
|
||||
res = OpenDatabases(server);
|
||||
res = OpenDatabases(server, isUpgrade);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("could not iterate over all databases: %s",
|
||||
|
@ -2075,7 +2082,7 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
|
|||
name,
|
||||
path);
|
||||
|
||||
vocbase = TRI_OpenVocBase(server, path, tick, name, defaults, false);
|
||||
vocbase = TRI_OpenVocBase(server, path, tick, name, defaults, false, false);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, path);
|
||||
|
||||
if (vocbase == NULL) {
|
||||
|
|
|
@ -412,12 +412,14 @@ trx_coordinator_t;
|
|||
|
||||
static int InsertTrxCallback (TRI_transaction_collection_t* trxCollection,
|
||||
void* data) {
|
||||
TRI_shaped_json_t* shaped;
|
||||
TRI_primary_collection_t* primary;
|
||||
TRI_memory_zone_t* zone;
|
||||
TRI_shaped_json_t* shaped;
|
||||
trx_coordinator_t* coordinator;
|
||||
int res;
|
||||
|
||||
primary = (TRI_primary_collection_t*) trxCollection->_collection->_collection;
|
||||
zone = primary->_shaper->_memoryZone;
|
||||
coordinator = data;
|
||||
|
||||
if (coordinator->_json == NULL) {
|
||||
|
@ -440,7 +442,7 @@ static int InsertTrxCallback (TRI_transaction_collection_t* trxCollection,
|
|||
false,
|
||||
false);
|
||||
|
||||
TRI_FreeShapedJson(primary->_shaper->_memoryZone, shaped);
|
||||
TRI_FreeShapedJson(zone, shaped);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1302,6 +1302,7 @@ int TRI_InsertAttributeVocShaper (TRI_shaper_t* s,
|
|||
f = TRI_InsertKeyAssociativeSynced(&shaper->_attributeIds, &m->_aid, m);
|
||||
assert(f == NULL);
|
||||
|
||||
// no lock is necessary here as we are the only users of the shaper at this time
|
||||
if (shaper->_nextAid <= m->_aid) {
|
||||
shaper->_nextAid = m->_aid + 1;
|
||||
}
|
||||
|
|
|
@ -850,7 +850,8 @@ static bool StartupTickIterator (TRI_df_marker_t const* marker,
|
|||
|
||||
static int ScanPath (TRI_vocbase_t* vocbase,
|
||||
char const* path,
|
||||
const bool iterateMarkers) {
|
||||
bool isUpgrade,
|
||||
bool iterateMarkers) {
|
||||
TRI_vector_string_t files;
|
||||
regmatch_t matches[2];
|
||||
regex_t re;
|
||||
|
@ -963,21 +964,12 @@ static int ScanPath (TRI_vocbase_t* vocbase,
|
|||
TRI_vocbase_col_t* c;
|
||||
|
||||
if (info._version < TRI_COL_VERSION) {
|
||||
LOG_INFO("upgrading collection '%s'", info._name);
|
||||
// collection is too "old"
|
||||
|
||||
res = TRI_ERROR_NO_ERROR;
|
||||
|
||||
if (info._version < TRI_COL_VERSION_13) {
|
||||
res = TRI_UpgradeCollection13(vocbase, file, &info);
|
||||
}
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR && info._version < TRI_COL_VERSION_15) {
|
||||
res = TRI_UpgradeCollection15(vocbase, file, &info);
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("upgrading collection '%s' failed.", info._name);
|
||||
|
||||
if (! isUpgrade) {
|
||||
LOG_ERROR("collection '%s' has a too old version. Please start the server with the --upgrade option.",
|
||||
info._name);
|
||||
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, file);
|
||||
TRI_DestroyVectorString(&files);
|
||||
TRI_FreeCollectionInfoOptions(&info);
|
||||
|
@ -985,7 +977,31 @@ static int ScanPath (TRI_vocbase_t* vocbase,
|
|||
|
||||
return TRI_set_errno(res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOG_INFO("upgrading collection '%s'", info._name);
|
||||
|
||||
res = TRI_ERROR_NO_ERROR;
|
||||
|
||||
if (info._version < TRI_COL_VERSION_13) {
|
||||
res = TRI_UpgradeCollection13(vocbase, file, &info);
|
||||
}
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR && info._version < TRI_COL_VERSION_15) {
|
||||
res = TRI_UpgradeCollection15(vocbase, file, &info);
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("upgrading collection '%s' failed.", info._name);
|
||||
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, file);
|
||||
TRI_DestroyVectorString(&files);
|
||||
TRI_FreeCollectionInfoOptions(&info);
|
||||
regfree(&re);
|
||||
|
||||
return TRI_set_errno(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c = AddCollection(vocbase, type, info._name, info._cid, file);
|
||||
|
||||
|
@ -1317,6 +1333,7 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server,
|
|||
TRI_voc_tick_t id,
|
||||
char const* name,
|
||||
TRI_vocbase_defaults_t const* defaults,
|
||||
bool isUpgrade,
|
||||
bool iterateMarkers) {
|
||||
TRI_vocbase_t* vocbase;
|
||||
int res;
|
||||
|
@ -1414,7 +1431,7 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server,
|
|||
// this will create the list of collections and their datafiles, and will also
|
||||
// determine the last tick values used (if iterateMarkers is true)
|
||||
|
||||
res = ScanPath(vocbase, vocbase->_path, iterateMarkers);
|
||||
res = ScanPath(vocbase, vocbase->_path, isUpgrade, iterateMarkers);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_FreeFunctionsAql(vocbase->_functions);
|
||||
|
|
|
@ -451,6 +451,7 @@ TRI_vocbase_t* TRI_OpenVocBase (struct TRI_server_s*,
|
|||
TRI_voc_tick_t,
|
||||
char const*,
|
||||
struct TRI_vocbase_defaults_s const*,
|
||||
bool,
|
||||
bool);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -2228,7 +2228,7 @@ void TRI_DestroyShapedJson (TRI_memory_zone_t* zone,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_FreeShapedJson (TRI_memory_zone_t* zone,
|
||||
TRI_shaped_json_t* shaped) {
|
||||
TRI_shaped_json_t* shaped) {
|
||||
TRI_DestroyShapedJson(zone, shaped);
|
||||
TRI_Free(zone, shaped);
|
||||
}
|
||||
|
@ -2241,7 +2241,8 @@ void TRI_FreeShapedJson (TRI_memory_zone_t* zone,
|
|||
/// @brief sorts a list of TRI_shape_value_t
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_SortShapeValues (TRI_shape_value_t* values, size_t n) {
|
||||
void TRI_SortShapeValues (TRI_shape_value_t* values,
|
||||
size_t n) {
|
||||
qsort(values, n, sizeof(TRI_shape_value_t), SortShapeValuesFunc);
|
||||
}
|
||||
|
||||
|
@ -2249,7 +2250,8 @@ void TRI_SortShapeValues (TRI_shape_value_t* values, size_t n) {
|
|||
/// @brief converts a json object into a shaped json object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_shaped_json_t* TRI_ShapedJsonJson (TRI_shaper_t* shaper, TRI_json_t const* json) {
|
||||
TRI_shaped_json_t* TRI_ShapedJsonJson (TRI_shaper_t* shaper,
|
||||
TRI_json_t const* json) {
|
||||
TRI_shaped_json_t* shaped;
|
||||
TRI_shape_value_t dst;
|
||||
bool ok;
|
||||
|
|
|
@ -304,7 +304,7 @@ typedef struct TRI_shape_value_s {
|
|||
TRI_shape_aid_t _aid; // attribute identifier
|
||||
TRI_shape_sid_t _sid; // shape identifier of the attribute
|
||||
TRI_shape_type_t _type; // type of the attribute
|
||||
bool _fixedSized; // true of all element of this shaped have the same size
|
||||
bool _fixedSized; // true of all element of this shape have the same size
|
||||
TRI_shape_size_t _size; // size of the data block
|
||||
|
||||
char* _value;
|
||||
|
|
Loading…
Reference in New Issue