Skip to content

Commit

Permalink
Fix clusterStateCache dataVersion bug
Browse files Browse the repository at this point in the history
--if there exists any path in the request that references a specific attribute, remove affacted wildcard cluster attribute in requestPathSet used in cached
so that we would not cache the dataVersion  for all clusters affected by that attribute.
  • Loading branch information
yunhanw-google committed May 19, 2022
1 parent 5d49116 commit 29dd861
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/app/AttributePathParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ struct AttributePathParams
{
VerifyOrReturnError(HasWildcardEndpointId() || other.HasWildcardEndpointId() || mEndpointId == other.mEndpointId, false);
VerifyOrReturnError(HasWildcardClusterId() || other.HasWildcardClusterId() || mClusterId == other.mClusterId, false);
VerifyOrReturnError(HasWildcardAttributeId() || other.HasWildcardAttributeId() || mAttributeId == other.mAttributeId, false);
VerifyOrReturnError(HasWildcardAttributeId() || other.HasWildcardAttributeId() || mAttributeId == other.mAttributeId,
false);
return true;
}

Expand Down
5 changes: 0 additions & 5 deletions src/app/ClusterStateCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,20 +470,15 @@ CHIP_ERROR ClusterStateCache::OnUpdateDataVersionFilterList(DataVersionFilterIBs
{
if (attribute1.IsAttributePathOverlapped(*attribute2))
{
ChipLogError(InteractionModel, "overlapped");
attribute2 = mRequestPathSet.erase(attribute2);
}
else
{
ChipLogError(InteractionModel, "!overlapped");
++attribute2;
}
}
}

ChipLogError(InteractionModel, "debug how many %lu", mRequestPathSet.size());


std::vector<std::pair<DataVersionFilter, size_t>> filterVector;
GetSortedFilters(filterVector);

Expand Down
9 changes: 3 additions & 6 deletions src/controller/tests/data_model/TestRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void TestReadInteraction::TestReadSubscribeAttributeResponseWithCache(nlTestSuit

int testId = 0;

// Read of E2C3A1, E*C3A1(1 supported attribute in E1C3A1), E2C3A* (3 supported attributes)
// Read of E2C3A1(dedup), E*C3A1(E1C3A1 not exit, E2C3A1 exist), E2C3A* (5 supported attributes)
// Expect no versions would be cached.
{
testId++;
Expand All @@ -410,14 +410,11 @@ void TestReadInteraction::TestReadSubscribeAttributeResponseWithCache(nlTestSuit
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

ctx.DrainAndServiceIO();
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 4);
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 6);
NL_TEST_ASSERT(apSuite, !delegate.mReadError);
Optional<DataVersion> version1;
NL_TEST_ASSERT(apSuite, cache.GetVersion(Test::kMockEndpoint1, Test::MockClusterId(3), version1) == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite, cache.GetVersion(Test::kMockEndpoint2, Test::MockClusterId(3), version1) == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite, !version1.HasValue());
Optional<DataVersion> version2;
NL_TEST_ASSERT(apSuite, cache.GetVersion(Test::kMockEndpoint2, Test::MockClusterId(3), version2) == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite, !version2.HasValue());
delegate.mNumAttributeResponse = 0;
}

Expand Down

0 comments on commit 29dd861

Please sign in to comment.