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
21 changes: 16 additions & 5 deletions src/tendisplus/replication/binlog_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
#include <iostream>
#include <set>
#include <string>
#include <vector>

#include "tendisplus/commands/command.h"
#include "tendisplus/commands/release.h"
#include "tendisplus/commands/version.h"
#include "tendisplus/storage/kvstore.h"
#include "tendisplus/storage/record.h"
#include "tendisplus/storage/varint.h"
#include "tendisplus/utils/base64.h"
#include "tendisplus/utils/param_manager.h"
#include "tendisplus/utils/time.h"

namespace tendisplus {

Expand Down Expand Up @@ -52,6 +51,8 @@ class BinlogScanner {
_matchKeySet.insert(key);
}
}
_max_key_size = pm.getUint64("max-key-size", _max_key_size);
_max_value_size = pm.getUint64("max-value-size", _max_value_size);
std::string detail = pm.getString("detail", "");
if (detail == "true") {
_detail = true;
Expand Down Expand Up @@ -90,12 +91,11 @@ class BinlogScanner {

if (logValue.value().getChunkId() == Transaction::CHUNKID_FLUSH) {
std::cout << binlogInfo.str();
std::cout << " op:" << "FLUSH" << " cmd:" << logValue.value().getCmd()
<< std::endl;
std::cout << " op:FLUSH cmd:" << logValue.value().getCmd() << std::endl;
return "";
} else if (logValue.value().getChunkId() == Transaction::CHUNKID_MIGRATE) {
std::cout << binlogInfo.str();
std::cout << " op:" << "MIGRATE" << " cmd:" << logValue.value().getCmd()
std::cout << " op:MIGRATE cmd:" << logValue.value().getCmd()
<< std::endl;
return "";
}
Expand Down Expand Up @@ -231,6 +231,9 @@ class BinlogScanner {
}
buff[sizeof(uint32_t)] = '\0';
keylen = int32Decode(buff);
if (keylen > _max_key_size)
return {ErrorCodes::ERR_INTERNAL,
"key size exceeds limit. key size: " + std::to_string(keylen)};

// key
std::string key;
Expand All @@ -250,6 +253,10 @@ class BinlogScanner {
}
buff[sizeof(uint32_t)] = '\0';
valuelen = int32Decode(buff);
if (valuelen > _max_value_size)
return {ErrorCodes::ERR_INTERNAL,
"value size exceeds limit. value size: " +
std::to_string(valuelen)};

// value
std::string value;
Expand Down Expand Up @@ -303,6 +310,9 @@ class BinlogScanner {
uint64_t _lastbinlogid = UINT64_MAX;
uint64_t _firstbinlogtime = UINT64_MAX;
uint64_t _lastbinlogtime = UINT64_MAX;

uint64_t _max_key_size = 512 * 1024 * 1024;
uint64_t _max_value_size = 512 * 1024 * 1024;
};

} // namespace tendisplus
Expand All @@ -313,6 +323,7 @@ void usage() {
<< " --start-position=333333 --end-position=55555"
<< " [--match-key=testKey --match-filed=testFiled]"
<< " [--match-key-list=testKey1,testKey2...]"
<< " [--max-key-size=536870912 --max-value-size=536870912]"
<< " [--detail=true/false]" << std::endl;
}

Expand Down
Loading