Skip to content

Commit

Permalink
Use a different letter to represent counter polling in sairedis.rec t…
Browse files Browse the repository at this point in the history
…o avoid saiplayer crash (sonic-net#1443)

Use a different letter to represent counter polling in sairedis.rec to avoid saiplayer crash

The character s was used for counter-polling polling which failed saiplayer because the format differed.
Now the character p is used to avoid failure. The saiplayer ignores p.

Signed-off-by: Stephen Sun <[email protected]>
  • Loading branch information
stephenxs authored and shiraez committed Dec 12, 2024
1 parent ded2846 commit 05d9f05
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ void Recorder::recordGenericSet(
recordLine("s|" + key + "|" + Globals::joinFieldValues(arguments));
}

void Recorder::recordGenericCounterPolling(
_In_ const std::string& key,
_In_ const std::vector<swss::FieldValueTuple>& arguments)
{
SWSS_LOG_ENTER();

// lower case 'p' stands for counter Polling

recordLine("p|" + key + "|" + Globals::joinFieldValues(arguments));
}

void Recorder::recordGenericSetResponse(
_In_ sai_status_t status)
{
Expand Down
4 changes: 4 additions & 0 deletions lib/Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ namespace sairedis

public: // SAI stats API

void recordGenericCounterPolling(
_In_ const std::string& key,
_In_ const std::vector<swss::FieldValueTuple>& arguments);

void recordGenericGetStats(
_In_ sai_object_type_t object_type,
_In_ sai_object_id_t object_id,
Expand Down
4 changes: 2 additions & 2 deletions lib/RedisRemoteSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ sai_status_t RedisRemoteSaiInterface::notifyCounterGroupOperations(
emplaceStrings(flexCounterGroupParam->plugin_name, flexCounterGroupParam->plugins, entries);
emplaceStrings(FLEX_COUNTER_STATUS_FIELD, flexCounterGroupParam->operation, entries);

m_recorder->recordGenericSet(key, entries);
m_recorder->recordGenericCounterPolling(key, entries);

m_communicationChannel->set(key,
entries,
Expand Down Expand Up @@ -607,7 +607,7 @@ sai_status_t RedisRemoteSaiInterface::notifyCounterOperations(
command = REDIS_FLEX_COUNTER_COMMAND_STOP_POLL;
}

m_recorder->recordGenericSet(key, entries);
m_recorder->recordGenericCounterPolling(key, entries);
m_communicationChannel->set(key, entries, command);

return waitForResponse(SAI_COMMON_API_SET);
Expand Down
3 changes: 3 additions & 0 deletions saiplayer/SaiPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2607,6 +2607,9 @@ int SaiPlayer::replay()
case 'q':
// TODO: implement SAI player support for query commands
continue;
case 'p':
// TODO: implement SAI player support for counter polling commands
continue;
case 'Q':
continue; // skip over query responses
case '#':
Expand Down
7 changes: 7 additions & 0 deletions tests/MLNX2700/full_no_hostif_entry.rec
Original file line number Diff line number Diff line change
Expand Up @@ -49647,3 +49647,10 @@
2017-05-11.01:45:41.511250|r|SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MEMBER:oid:0x2d000000000656
2017-05-11.01:44:02.533119|a|APPLY_VIEW
2017-05-11.01:44:02.535313|A|SAI_STATUS_SUCCESS
2024-11-02.06:13:50.487652|p|BUFFER_POOL_WATERMARK_STAT_COUNTER|POLL_INTERVAL=60000|BUFFER_POOL_PLUGIN_LIST=78f7658e05f9659b8ecaf00eb0214957a509e246
2024-11-02.06:14:06.920978|p|BUFFER_POOL_WATERMARK_STAT_COUNTER|STATS_MODE=STATS_MODE_READ_AND_CLEAR
2024-11-02.06:14:06.922388|p|BUFFER_POOL_WATERMARK_STAT_COUNTER:oid:0x1800000000069d|BUFFER_POOL_COUNTER_ID_LIST=SAI_BUFFER_POOL_STAT_WATERMARK_BYTES,SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES
2024-11-02.06:14:06.923907|p|BUFFER_POOL_WATERMARK_STAT_COUNTER:oid:0x1800000000069e|BUFFER_POOL_COUNTER_ID_LIST=SAI_BUFFER_POOL_STAT_WATERMARK_BYTES,SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES
2024-11-02.06:14:06.925866|p|BUFFER_POOL_WATERMARK_STAT_COUNTER:oid:0x1800000000069f|BUFFER_POOL_COUNTER_ID_LIST=SAI_BUFFER_POOL_STAT_WATERMARK_BYTES,SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES
2024-11-02.06:14:06.927241|p|BUFFER_POOL_WATERMARK_STAT_COUNTER:oid:0x180000000006a0|BUFFER_POOL_COUNTER_ID_LIST=SAI_BUFFER_POOL_STAT_WATERMARK_BYTES,SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES
2024-11-02.06:14:06.928549|p|BUFFER_POOL_WATERMARK_STAT_COUNTER|FLEX_COUNTER_STATUS=enable

0 comments on commit 05d9f05

Please sign in to comment.