mirror of
https://github.com/typesense/typesense.git
synced 2025-05-21 14:12:27 +08:00
Fix locking test failures.
This commit is contained in:
parent
b9e1cd61e3
commit
3071389648
@ -441,9 +441,12 @@ Option<Collection*> CollectionManager::create_collection(const std::string& name
|
||||
return Option<Collection*>(fields_json_op.code(), fields_json_op.error());
|
||||
}
|
||||
|
||||
uint32_t new_coll_id = next_collection_id;
|
||||
next_collection_id++;
|
||||
|
||||
nlohmann::json collection_meta;
|
||||
collection_meta[Collection::COLLECTION_NAME_KEY] = name;
|
||||
collection_meta[Collection::COLLECTION_ID_KEY] = next_collection_id.load();
|
||||
collection_meta[Collection::COLLECTION_ID_KEY] = new_coll_id;
|
||||
collection_meta[Collection::COLLECTION_SEARCH_FIELDS_KEY] = fields_json;
|
||||
collection_meta[Collection::COLLECTION_DEFAULT_SORTING_FIELD_KEY] = default_sorting_field;
|
||||
collection_meta[Collection::COLLECTION_CREATED] = created_at;
|
||||
@ -453,13 +456,6 @@ Option<Collection*> CollectionManager::create_collection(const std::string& name
|
||||
collection_meta[Collection::COLLECTION_SEPARATORS] = token_separators;
|
||||
collection_meta[Collection::COLLECTION_ENABLE_NESTED_FIELDS] = enable_nested_fields;
|
||||
|
||||
Collection* new_collection = new Collection(name, next_collection_id, created_at, 0, store, fields,
|
||||
default_sorting_field,
|
||||
this->max_memory_ratio, fallback_field_type,
|
||||
symbols_to_index, token_separators,
|
||||
enable_nested_fields);
|
||||
next_collection_id++;
|
||||
|
||||
rocksdb::WriteBatch batch;
|
||||
batch.Put(Collection::get_next_seq_id_key(name), StringUtils::serialize_uint32_t(0));
|
||||
batch.Put(Collection::get_meta_key(name), collection_meta.dump());
|
||||
@ -471,8 +467,17 @@ Option<Collection*> CollectionManager::create_collection(const std::string& name
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
|
||||
Collection* new_collection = new Collection(name, new_coll_id, created_at, 0, store, fields,
|
||||
default_sorting_field,
|
||||
this->max_memory_ratio, fallback_field_type,
|
||||
symbols_to_index, token_separators,
|
||||
enable_nested_fields);
|
||||
|
||||
add_to_collections(new_collection);
|
||||
|
||||
lock.lock();
|
||||
|
||||
if (referenced_in_backlog.count(name) > 0) {
|
||||
new_collection->add_referenced_ins(referenced_in_backlog.at(name));
|
||||
referenced_in_backlog.erase(name);
|
||||
@ -1867,6 +1872,8 @@ Option<bool> CollectionManager::load_collection(const nlohmann::json &collection
|
||||
LOG(INFO) << "Indexed " << num_indexed_docs << "/" << num_found_docs
|
||||
<< " documents into collection " << collection->get_name();
|
||||
|
||||
collection->_get_index()->log_insert_time = true;
|
||||
collection->_get_index()->_get_facet_index()->log_insert_time = true;
|
||||
return Option<bool>(true);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user