Add ProducerStateTable temp view implementation and UT#247
Add ProducerStateTable temp view implementation and UT#247taoyl-ms merged 8 commits intosonic-net:masterfrom
Conversation
|
|
||
| static inline string key(int i) | ||
| { | ||
| return string("key ") + to_string(i); |
There was a problem hiding this comment.
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.
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.
| @@ -0,0 +1,16 @@ | |||
| local arg_start = 2 | |||
There was a problem hiding this comment.
Suggest add file header comments to describe the usage, such as parameters. #Closed
There was a problem hiding this comment.
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.
dump [](start = 18, length = 4)
There is a comment "note that this function is not efficient"... #Closed
There was a problem hiding this comment.
There was a problem hiding this comment.
There was a problem hiding this comment.
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.
follow existing coding style? #Closed
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.
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.
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.
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.
Excluding keys for del operation, It looks duplicate key data provided in KEYS and ARGV? #ByDesign
There was a problem hiding this comment.
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.
skeys [](start = 9, length = 5)
skeys is not used and can be removed. #Resolved
jipanyang
left a comment
There was a problem hiding this comment.
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.
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.
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.
* [SFP-Refactor] Fix LP mode API issue * update API
See detail in design doc: https://github.com/Azure/SONiC/blob/master/doc/warm-reboot/view_switch.md