Skip to content
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

Merged
merged 8 commits into from
Nov 16, 2018

Conversation

taoyl-ms
Copy link
Contributor

@taoyl-ms taoyl-ms requested a review from qiluo-msft November 10, 2018 00:41
@@ -29,18 +29,18 @@ static inline int getMaxFields(int i)

static inline string key(int i)
{
return string("key ") + to_string(i);
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 10, 2018

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);
}
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 10, 2018

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:

  1. create
  2. create
  3. apply

Double apply:

  1. create
  2. apply
  3. apply

Delete all:

  1. create
  2. set many
  3. delete all
  4. apply

Empty view (ie. clear)

  1. create
  2. immediately apply
    #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases added according to CR comments.


In reply to: 232432588 [](ancestors = 232432588)

@@ -0,0 +1,16 @@
local arg_start = 2
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 10, 2018

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

Copy link
Contributor Author

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);
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 10, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're calling it only once here as well.


In reply to: 232433590 [](ancestors = 232433590)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even once, it is still not efficient.


In reply to: 232849738 [](ancestors = 232849738,232433590)

Copy link
Contributor Author

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)

}
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
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 10, 2018

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

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments.

std::vector<std::string> keysToSet;
std::vector<std::string> keysToDel;

// Compare based on existing objects
Copy link
Contributor

@jipanyang jipanyang Nov 10, 2018

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

Copy link
Contributor Author

@taoyl-ms taoyl-ms Nov 12, 2018

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)

Copy link
Contributor

@jipanyang jipanyang Nov 13, 2018

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

// G (String to be published to channel)
// 2 (Count of objects to set)
// key_0
// key_1
Copy link
Contributor

@jipanyang jipanyang Nov 10, 2018

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

Copy link
Contributor Author

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)

@@ -4,10 +4,11 @@ local res = {}
for i,k in pairs(keys) do

local skeys = redis.call("HKEYS", k)
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 15, 2018

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

@qiluo-msft qiluo-msft dismissed their stale review November 15, 2018 04:45

Minor issue remains. Unblocked.

Copy link
Contributor

@jipanyang jipanyang left a 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}


// 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:");
Copy link
Contributor

@jipanyang jipanyang Nov 16, 2018

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);
Copy link
Contributor

@jipanyang jipanyang Nov 16, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Unit test already covered empty values.


In reply to: 234321630 [](ancestors = 234321630)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants