Skip to content

Commit d0d2334

Browse files
committed
MB-28289: Fix SegFault in GetFailoverLog for non-existing VBucket
The legacy DCP GetFailoverLog logs a message if a non-existing VBucket is requested. This message includes the DCP connection prefix string. For non-DCP connections we do not have any prefix, so we set it to "MCBP-Connection". Change-Id: Icc7d8aca030a15876c2449f336c1a429c68cd1f5 Reviewed-on: http://review.couchbase.org/90743 Reviewed-by: Dave Rigby <[email protected]> Tested-by: Build Bot <[email protected]> Reviewed-by: Tim Bradgate <[email protected]>
1 parent 3927b53 commit d0d2334

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

engines/ep/src/ep_engine.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ static ENGINE_ERROR_CODE EvpDcpGetFailoverLog(
13921392
LOG(EXTENSION_LOG_WARNING,
13931393
"%s (vb %d) Get Failover Log failed because this vbucket doesn't "
13941394
"exist",
1395-
conn->logHeader(),
1395+
conn ? conn->logHeader() : "MCBP-Connection",
13961396
vbucket);
13971397
return ENGINE_NOT_MY_VBUCKET;
13981398
}

tests/testapp/testapp_misc.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,31 @@ TEST_P(MiscTest, GetFailoverLog) {
3333
TESTAPP_SKIP_IF_UNSUPPORTED(PROTOCOL_BINARY_CMD_GET_FAILOVER_LOG);
3434

3535
auto& connection = getConnection();
36+
37+
// Test existing VBucket
3638
auto response = connection.getFailoverLog(0 /*vbid*/);
3739
auto header = response.getHeader().response;
38-
3940
EXPECT_EQ(header.magic, PROTOCOL_BINARY_RES);
4041
EXPECT_EQ(header.opcode, PROTOCOL_BINARY_CMD_GET_FAILOVER_LOG);
4142
EXPECT_EQ(header.keylen, 0);
4243
EXPECT_EQ(header.extlen, 0);
4344
EXPECT_EQ(header.datatype, 0);
44-
EXPECT_EQ(header.status, 0);
45+
EXPECT_EQ(header.status, PROTOCOL_BINARY_RESPONSE_SUCCESS);
4546
// Note: We expect 1 entry in the failover log, which is the entry created
4647
// at VBucket creation (8 bytes for UUID + 8 bytes for SEQNO)
4748
EXPECT_EQ(ntohl(header.bodylen), 0x10);
4849
EXPECT_EQ(header.cas, 0);
49-
5050
EXPECT_EQ(response.getData().len, 0x10);
51+
52+
// Test non-existing VBucket
53+
response = connection.getFailoverLog(1 /*vbid*/);
54+
header = response.getHeader().response;
55+
EXPECT_EQ(header.magic, PROTOCOL_BINARY_RES);
56+
EXPECT_EQ(header.opcode, PROTOCOL_BINARY_CMD_GET_FAILOVER_LOG);
57+
EXPECT_EQ(header.keylen, 0);
58+
EXPECT_EQ(header.extlen, 0);
59+
EXPECT_EQ(header.datatype, 0);
60+
EXPECT_EQ(header.status, PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET);
61+
EXPECT_EQ(ntohl(header.bodylen), 0);
62+
EXPECT_EQ(header.cas, 0);
5163
}

0 commit comments

Comments
 (0)