mirror of https://github.com/milvus-io/milvus.git
feat(db): remove mutex for meta operation
Former-commit-id: 349c7856679f76eedd9c29f0208bd27beae93b33pull/191/head
parent
a6e92dc9ab
commit
ef59efc76a
|
@ -76,6 +76,7 @@ Status DBMetaImpl::initialize() {
|
||||||
ConnectorPtr = std::make_unique<ConnectorT>(StoragePrototype(_options.path+"/meta.sqlite"));
|
ConnectorPtr = std::make_unique<ConnectorT>(StoragePrototype(_options.path+"/meta.sqlite"));
|
||||||
|
|
||||||
ConnectorPtr->sync_schema();
|
ConnectorPtr->sync_schema();
|
||||||
|
ConnectorPtr->open_forever(); // thread safe option
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
|
@ -93,8 +94,6 @@ Status DBMetaImpl::add_group(GroupSchema& group_info) {
|
||||||
group_info.id = -1;
|
group_info.id = -1;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto id = ConnectorPtr->insert(group_info);
|
auto id = ConnectorPtr->insert(group_info);
|
||||||
group_info.id = id;
|
group_info.id = id;
|
||||||
|
@ -114,7 +113,6 @@ Status DBMetaImpl::add_group(GroupSchema& group_info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DBMetaImpl::get_group(GroupSchema& group_info) {
|
Status DBMetaImpl::get_group(GroupSchema& group_info) {
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
return get_group_no_lock(group_info);
|
return get_group_no_lock(group_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +137,6 @@ Status DBMetaImpl::get_group_no_lock(GroupSchema& group_info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DBMetaImpl::has_group(const std::string& group_id, bool& has_or_not) {
|
Status DBMetaImpl::has_group(const std::string& group_id, bool& has_or_not) {
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
auto groups = ConnectorPtr->select(columns(&GroupSchema::id),
|
auto groups = ConnectorPtr->select(columns(&GroupSchema::id),
|
||||||
where(c(&GroupSchema::group_id) == group_id));
|
where(c(&GroupSchema::group_id) == group_id));
|
||||||
assert(groups.size() <= 1);
|
assert(groups.size() <= 1);
|
||||||
|
@ -171,8 +168,6 @@ Status DBMetaImpl::add_group_file(GroupFileSchema& group_file) {
|
||||||
GetGroupFilePath(group_file);
|
GetGroupFilePath(group_file);
|
||||||
|
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto id = ConnectorPtr->insert(group_file);
|
auto id = ConnectorPtr->insert(group_file);
|
||||||
group_file.id = id;
|
group_file.id = id;
|
||||||
|
@ -194,7 +189,6 @@ Status DBMetaImpl::add_group_file(GroupFileSchema& group_file) {
|
||||||
Status DBMetaImpl::files_to_index(GroupFilesSchema& files) {
|
Status DBMetaImpl::files_to_index(GroupFilesSchema& files) {
|
||||||
files.clear();
|
files.clear();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
auto selected = ConnectorPtr->select(columns(&GroupFileSchema::id,
|
auto selected = ConnectorPtr->select(columns(&GroupFileSchema::id,
|
||||||
&GroupFileSchema::group_id,
|
&GroupFileSchema::group_id,
|
||||||
&GroupFileSchema::file_id,
|
&GroupFileSchema::file_id,
|
||||||
|
@ -235,7 +229,6 @@ Status DBMetaImpl::files_to_merge(const std::string& group_id,
|
||||||
DatePartionedGroupFilesSchema& files) {
|
DatePartionedGroupFilesSchema& files) {
|
||||||
files.clear();
|
files.clear();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
auto selected = ConnectorPtr->select(columns(&GroupFileSchema::id,
|
auto selected = ConnectorPtr->select(columns(&GroupFileSchema::id,
|
||||||
&GroupFileSchema::group_id,
|
&GroupFileSchema::group_id,
|
||||||
&GroupFileSchema::file_id,
|
&GroupFileSchema::file_id,
|
||||||
|
@ -294,7 +287,6 @@ Status DBMetaImpl::get_group_files(const std::string& group_id_,
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DBMetaImpl::update_group_file(const GroupFileSchema& group_file) {
|
Status DBMetaImpl::update_group_file(const GroupFileSchema& group_file) {
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
auto commited = ConnectorPtr->transaction([&] () mutable {
|
auto commited = ConnectorPtr->transaction([&] () mutable {
|
||||||
ConnectorPtr->update(group_file);
|
ConnectorPtr->update(group_file);
|
||||||
return true;
|
return true;
|
||||||
|
@ -306,7 +298,6 @@ Status DBMetaImpl::update_group_file(const GroupFileSchema& group_file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DBMetaImpl::update_files(const GroupFilesSchema& files) {
|
Status DBMetaImpl::update_files(const GroupFilesSchema& files) {
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
auto commited = ConnectorPtr->transaction([&] () mutable {
|
auto commited = ConnectorPtr->transaction([&] () mutable {
|
||||||
for (auto& file : files) {
|
for (auto& file : files) {
|
||||||
ConnectorPtr->update(file);
|
ConnectorPtr->update(file);
|
||||||
|
@ -320,7 +311,6 @@ Status DBMetaImpl::update_files(const GroupFilesSchema& files) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DBMetaImpl::cleanup() {
|
Status DBMetaImpl::cleanup() {
|
||||||
std::unique_lock<std::mutex> lk(mutex_);
|
|
||||||
auto selected = ConnectorPtr->select(columns(&GroupFileSchema::id,
|
auto selected = ConnectorPtr->select(columns(&GroupFileSchema::id,
|
||||||
&GroupFileSchema::group_id,
|
&GroupFileSchema::group_id,
|
||||||
&GroupFileSchema::file_id,
|
&GroupFileSchema::file_id,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef VECENGINE_DB_META_IMPL_H_
|
#ifndef VECENGINE_DB_META_IMPL_H_
|
||||||
#define VECENGINE_DB_META_IMPL_H_
|
#define VECENGINE_DB_META_IMPL_H_
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <mutex>
|
|
||||||
#include "Meta.h"
|
#include "Meta.h"
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
|
|
||||||
|
@ -55,8 +53,6 @@ private:
|
||||||
Status initialize();
|
Status initialize();
|
||||||
|
|
||||||
const DBMetaOptions _options;
|
const DBMetaOptions _options;
|
||||||
std::mutex mutex_;
|
|
||||||
|
|
||||||
}; // DBMetaImpl
|
}; // DBMetaImpl
|
||||||
|
|
||||||
} // namespace meta
|
} // namespace meta
|
||||||
|
|
Loading…
Reference in New Issue