Skip to content

Commit fb83597

Browse files
committed
MB-58646: Disallow getting command timings for not current bucket
This was broken for a long time and mctimings selects the bucket first hence not entering the erroneous code path. Change-Id: Id470619de431d429655e4940c42a5999b09d6a42 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/197182 Reviewed-by: Trond Norbye <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 2b05c95 commit fb83597

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

daemon/protocol/mcbp/get_cmd_timer_executor.cc

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -174,27 +174,9 @@ std::pair<cb::engine_errc, std::string> get_cmd_timer(Cookie& cookie) {
174174
return std::make_pair(bt.first, std::string{});
175175
}
176176

177-
// The user specified a bucket... let's locate the bucket
178-
std::pair<cb::engine_errc, Hdr1sfMicroSecHistogram> ret;
179-
180-
for (auto& b : all_buckets) {
181-
ret = maybe_get_timings(cookie, b, opcode, bucket);
182-
if (ret.first != cb::engine_errc::no_such_key &&
183-
ret.first != cb::engine_errc::success) {
184-
break;
185-
}
186-
}
187-
188-
if (ret.first == cb::engine_errc::success) {
189-
return std::make_pair(cb::engine_errc::success, ret.second.to_string());
190-
}
191-
192-
if (ret.first == cb::engine_errc::no_such_key) {
193-
// Don't tell the user that the bucket doesn't exist
194-
ret.first = cb::engine_errc::no_access;
195-
}
196-
197-
return std::make_pair(ret.first, std::string{});
177+
// We removed support for getting command timings for not the current bucket
178+
// as it was broken and unused
179+
return std::make_pair(cb::engine_errc::not_supported, std::string{});
198180
}
199181

200182
void get_cmd_timer_executor(Cookie& cookie) {

tests/testapp/testapp_cmd_timers.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,19 @@ TEST_P(CmdTimerTest, CurrentBucket) {
126126
});
127127
}
128128

129+
/**
130+
* We removed support for getting command timings for not the current bucket
131+
* as it was broken and unused
132+
*/
133+
TEST_P(CmdTimerTest, NotCurrentBucket) {
134+
adminConnection->executeInBucket(bucketName, [this](auto& c) {
135+
const auto response = c.execute(BinprotGetCmdTimerCommand{
136+
"rbac_test", cb::mcbp::ClientOpcode::Scrub});
137+
EXPECT_FALSE(response.isSuccess());
138+
EXPECT_EQ(cb::mcbp::Status::NotSupported, response.getStatus());
139+
});
140+
}
141+
129142
/**
130143
* We should get no access for unknown buckets
131144
*/

0 commit comments

Comments
 (0)