-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ProducerStateTable temp view implementation and UT #247
Conversation
tests/redis_state_ut.cpp
Outdated
@@ -29,18 +29,18 @@ static inline int getMaxFields(int i) | |||
|
|||
static inline string key(int i) | |||
{ | |||
return string("key ") + to_string(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key [](start = 19, length = 4)
The original test data may be better, it is testing a key/field/value with blank char. #Closed
hlen.format("HLEN %s", (c.getKeyName(key(0))).c_str()); | ||
RedisReply r6(&db, hlen, REDIS_REPLY_INTEGER); | ||
EXPECT_EQ(r6.getReply<long long int>(), (long long int) maxNumOfFieldsNew); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion test cases on corner flows if not covered already.
Double create:
- create
- create
- apply
Double apply:
- create
- apply
- apply
Delete all:
- create
- set many
- delete all
- apply
Empty view (ie. clear)
- create
- immediately apply
#Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,16 @@ | |||
local arg_start = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest add file header comments to describe the usage, such as parameters. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put them in apply_view() function in producerstatetable.cpp. Do you think here will be a better place?
In reply to: 232432763 [](ancestors = 232432763)
TableDump currentState; | ||
{ | ||
Table mainTable(m_pipe, getTableName(), false); | ||
mainTable.dump(currentState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dump [](start = 18, length = 4)
There is a comment "note that this function is not efficient"... #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I'll refine the implementation for better performance.
In reply to: 233584343 [](ancestors = 233584343,232849738,232433590)
common/producerstatetable.cpp
Outdated
} | ||
if (needDel) keysToDel.emplace_back(key); | ||
if (needSet) keysToSet.emplace_back(key); | ||
else m_tempViewState.erase(key); // If exactly match, no need to sync new state to StateHash in DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow existing coding style? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As comments.
common/producerstatetable.cpp
Outdated
std::vector<std::string> keysToSet; | ||
std::vector<std::string> keysToDel; | ||
|
||
// Compare based on existing objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be helpful if some debug level log is available to dump the data in current view and tmp view. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means to dump the entire table? Wouldn't there be too many logs?
In reply to: 232442252 [](ancestors = 232442252)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is one time thing, usually warm restart only. For debugging purpose, I think it is ok and helpful. #Resolved
common/producerstatetable.cpp
Outdated
// G (String to be published to channel) | ||
// 2 (Count of objects to set) | ||
// key_0 | ||
// key_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excluding keys for del operation, It looks duplicate key data provided in KEYS and ARGV? #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically yes, since all KEYS for StateHash has a corresponding key to set in KeySet. However, One of them has format '_SAMPLE:key_0' and is actual key of redis object, and another one has format 'key_0' and is not object key (therefore should not be passed in KEYS), I'll prefer to pass them as KEYS and ARGV seperatedly.
In reply to: 232443018 [](ancestors = 232443018)
common/table_dump.lua
Outdated
@@ -4,10 +4,11 @@ local res = {} | |||
for i,k in pairs(keys) do | |||
|
|||
local skeys = redis.call("HKEYS", k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skeys [](start = 9, length = 5)
skeys is not used and can be removed. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the changes look good to me.
Could you add comments about the case as seen with fpmsyncd? They are not supported in current library.
* FV1 {nexthop: 10.1.1.1, 10.1.1.2}
* FV2 {nexthop: 10.1.1.2, 10.1.1.1}
common/producerstatetable.cpp
Outdated
|
||
// Print content of current view and temp view as debug log | ||
SWSS_LOG_DEBUG("View switch of table %s required.", getTableName().c_str()); | ||
SWSS_LOG_DEBUG("Objects in current view:"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so sure, would INFO level be better considering this is kind of critical data when debugging possible reconciliation issue, there is so much routine debug level messages in different modules as of today. #Resolved
// Write to temp view instead of DB | ||
for (const auto& iv: values) | ||
{ | ||
m_tempViewState[key][fvField(iv)] = fvValue(iv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is case like below also ok? is that covered in unit test?
127.0.0.1:6379[4]> hgetall hello
1) ""
2) ""
``` #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See detail in design doc: https://github.com/Azure/SONiC/blob/master/doc/warm-reboot/view_switch.md