Skip to content

Commit

Permalink
[Update] not use WriteBatchInspector in Replication code
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Nov 4, 2022
1 parent cad1820 commit a1ea781
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 2 additions & 8 deletions src/cluster/replication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void FeedSlaveThread::loop() {
batches_bulk += Redis::BulkString(batch.writeBatchPtr->Data());
// 1. We must send the first replication batch, as said above.
// 2. To avoid frequently calling 'write' system call to send replication stream,
// we pack multiple bacthes into one big bulk if possible, and only send once.
// we pack multiple batches into one big bulk if possible, and only send once.
// But we should send the bulk of batches if its size exceed kMaxDelayBytes,
// 16Kb by default. Moreover, we also send if updates count in all bathes is
// more that kMaxDelayUpdates, to void too many delayed updates.
Expand Down Expand Up @@ -895,14 +895,8 @@ void ReplicationThread::EventTimerCB(int, int16_t, void *ctx) {

rocksdb::Status ReplicationThread::ParseWriteBatch(const std::string &batch_string) {
rocksdb::WriteBatch write_batch(batch_string);
rocksdb::Status status;

// TODO(mapleFU): only for debugging, remove it later.
WriteBatchInspector inspector;
status = write_batch.Iterate(&inspector);
LOG(INFO) << inspector.seen << ", cnt: " << inspector.cnt;

WriteBatchHandler write_batch_handler;
rocksdb::Status status;

status = write_batch.Iterate(&write_batch_handler);
if (!status.ok()) return status;
Expand Down
10 changes: 8 additions & 2 deletions src/storage/batch_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@
#include <rocksdb/db.h>
#include <rocksdb/slice.h>

#include <map>
#include <string>
#include <vector>

/// Usage:
///
/// ```
/// WriteBatchInspector inspector;
/// status = write_batch.Iterate(&inspector);
/// LOG(INFO) << inspector.seen << ", cnt: " << inspector.cnt;
/// ```
struct WriteBatchInspector : public rocksdb::WriteBatch::Handler {
std::string seen;
int cnt = 0;
Expand Down Expand Up @@ -120,4 +126,4 @@ struct WriteBatchInspector : public rocksdb::WriteBatch::Handler {
seen += "MarkRollback(" + xid.ToString() + ")";
return rocksdb::Status::OK();
}
};
};

0 comments on commit a1ea781

Please sign in to comment.