Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions src/db/collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,8 @@ Status CollectionImpl::validate(const std::string &column,
return Status::InvalidArgument("Column name is empty");
}
if (schema_->has_field(schema->name())) {
return Status::InvalidArgument("column already exists");
return Status::InvalidArgument("column already exists: ",
schema->name());
}

auto s = schema->validate();
Expand All @@ -1064,7 +1065,8 @@ Status CollectionImpl::validate(const std::string &column,

if (expression.empty() && !schema->nullable()) {
return Status::InvalidArgument(
"Add column is not supported for non-nullable column");
"Add column is not supported for non-nullable column: ",
schema->name());
}

break;
Expand Down Expand Up @@ -1445,7 +1447,9 @@ Result<WriteResults> CollectionImpl::write_impl(std::vector<Doc> &docs,
WriteResults results;
// validate write batch size
if (docs.size() > kMaxWriteBatchSize) {
CHECK_RETURN_STATUS_EXPECTED(Status::InvalidArgument("Too many docs"));
CHECK_RETURN_STATUS_EXPECTED(Status::InvalidArgument(
"Too many docs: ", docs.size(),
" exceeds max write batch size ", kMaxWriteBatchSize));
}

// validate docs
Expand Down Expand Up @@ -1562,7 +1566,7 @@ Status CollectionImpl::DeleteByFilter(const std::string &filter) {
for (auto &doc : ret.value()) {
Status s = writing_segment_->Delete(doc->doc_id());
if (!s.ok()) {
LOG_ERROR("Delete doc_id failed");
LOG_ERROR("Delete doc_id: %zu failed", (size_t)doc->doc_id());
return s;
}
}
Expand Down Expand Up @@ -1700,7 +1704,7 @@ Status CollectionImpl::recover_idmap_and_delete_store() {
id_map_ = IDMap::CreateAndOpen(schema_->name(), idmap_path, false,
options_.read_only_);
if (!id_map_) {
return Status::InternalError("recovery idmap failed");
return Status::InternalError("recovery idmap failed, path: ", idmap_path);
}

// delete store
Expand All @@ -1709,7 +1713,8 @@ Status CollectionImpl::recover_idmap_and_delete_store() {
delete_store_ =
DeleteStore::CreateAndLoad(schema_->name(), delete_store_path);
if (!delete_store_) {
return Status::InternalError("recovery delete store failed");
return Status::InternalError("recovery delete store failed, path: ",
delete_store_path);
}

return Status::OK();
Expand Down Expand Up @@ -1779,7 +1784,7 @@ Status CollectionImpl::create_idmap_and_delete_store() {
id_map_ = IDMap::CreateAndOpen(schema_->name(), idmap_path, true,
options_.read_only_);
if (!id_map_) {
return Status::InternalError("create id map failed");
return Status::InternalError("create id map failed, path: ", idmap_path);
}

std::string delete_store_path =
Expand Down Expand Up @@ -1825,21 +1830,24 @@ Status CollectionImpl::acquire_file_lock(bool create) {

if (create) {
if (!lock_file_.create(lock_file_path.c_str(), 0)) {
return Status::InternalError("Can't create lock file");
return Status::InternalError("Can't create lock file: ",
lock_file_path);
}
} else {
if (!lock_file_.open(lock_file_path.c_str(), false)) {
return Status::InternalError("Can't open lock file");
return Status::InternalError("Can't open lock file: ", lock_file_path);
}
}

if (options_.read_only_) {
if (!ailego::FileLock::TryLockShared(lock_file_.native_handle())) {
return Status::InternalError("Can't lock read-only collection");
return Status::InternalError("Can't lock read-only collection: ",
lock_file_path);
}
} else {
if (!ailego::FileLock::TryLock(lock_file_.native_handle())) {
return Status::InternalError("Can't lock read-write collection");
return Status::InternalError("Can't lock read-write collection: ",
lock_file_path);
}
}

Expand Down
Loading