PragmaTwice commented on code in PR #3322:
URL: https://github.com/apache/kvrocks/pull/3322#discussion_r2657878791
##########
src/types/redis_string.cc:
##########
@@ -395,43 +395,38 @@ rocksdb::Status String::IncrByFloat(engine::Context &ctx,
const std::string &use
}
rocksdb::Status String::MSet(engine::Context &ctx, const
std::vector<StringPair> &pairs, StringMSetArgs args,
- bool *flag) {
- if (flag != nullptr) {
- *flag = false;
- }
-
- if (args.type != StringSetType::NONE) {
- int exists = 0;
- int key_count = static_cast<int>(pairs.size());
- std::vector<Slice> keys;
- keys.reserve(pairs.size());
- for (const auto &pair : pairs) {
- keys.emplace_back(pair.key);
- }
- auto s = Exists(ctx, keys, &exists);
- if (!s.ok()) return s;
- if ((args.type == StringSetType::NX && exists > 0) || (args.type ==
StringSetType::XX && exists < key_count)) {
- return rocksdb::Status::OK();
- }
- }
+ bool *flag = nullptr) {
+ if (flag) *flag = false;
auto batch = storage_->GetWriteBatchBase();
WriteBatchLogData log_data(kRedisString);
- rocksdb::Status s = batch->PutLogData(log_data.Encode());
+ auto s = batch->PutLogData(log_data.Encode());
Review Comment:
I think we should get and modify the batch after all checks (e.g. NX/XX
checks below). Even we don't write this batch into storage, in transaction mode
we'll use this batch to commit.
##########
src/types/redis_string.cc:
##########
@@ -395,43 +395,38 @@ rocksdb::Status String::IncrByFloat(engine::Context &ctx,
const std::string &use
}
rocksdb::Status String::MSet(engine::Context &ctx, const
std::vector<StringPair> &pairs, StringMSetArgs args,
- bool *flag) {
- if (flag != nullptr) {
- *flag = false;
- }
-
- if (args.type != StringSetType::NONE) {
- int exists = 0;
- int key_count = static_cast<int>(pairs.size());
- std::vector<Slice> keys;
- keys.reserve(pairs.size());
- for (const auto &pair : pairs) {
- keys.emplace_back(pair.key);
- }
- auto s = Exists(ctx, keys, &exists);
- if (!s.ok()) return s;
- if ((args.type == StringSetType::NX && exists > 0) || (args.type ==
StringSetType::XX && exists < key_count)) {
- return rocksdb::Status::OK();
- }
- }
+ bool *flag = nullptr) {
+ if (flag) *flag = false;
auto batch = storage_->GetWriteBatchBase();
WriteBatchLogData log_data(kRedisString);
- rocksdb::Status s = batch->PutLogData(log_data.Encode());
+ auto s = batch->PutLogData(log_data.Encode());
Review Comment:
I think we should get and modify the batch after all checks (e.g. NX/XX
checks below). Even we don't write this batch into storage, in transaction mode
we'll use this batch to commit. cc @git-hulk
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]