-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Cached counter file is not cleared during config reload, causing portstat give wrong counter values #9817
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
Cached counter file is not cleared during config reload, causing portstat give wrong counter values #9817
Comments
This kind of cached files should be cleared during |
The bug is also valid for ACL/PBH counters:
|
I see that for some counters (e.g dropstat) the cache file is cleared on config reload, code. To solve this I propose:
|
@stepanblyschak how about |
- What I did To fix sonic-net/sonic-buildimage#9817. Cache all counters in the same place. Created a UserCache helper class to access the cache directory. - How I did it Implemented UserCache class. Changed all stats commands to use new class. Adopted fast-reboot script. - How to verify it Run on the switch and verify counters stats command and clear commands work correctly. After config reload or cold/fast reboot counters cache is removed. Signed-off-by: Stepan Blyschak <[email protected]>
A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location. - Why I did it To fix #9817. Clear the cache directory on swss.sh except for warm start. Also, adopted finalize-warmboot script to take the cache directory. - How I did it A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location. - How to verify it Run togather with sonic-net/sonic-utilities#2232. Verify counters cache is removed on config reload, cold/fast reboots, swss restart. Signed-off-by: Stepan Blyschak <[email protected]>
- What I did To fix sonic-net/sonic-buildimage#9817. Cache all counters in the same place. Created a UserCache helper class to access the cache directory. - How I did it Implemented UserCache class. Changed all stats commands to use new class. Adopted fast-reboot script. - How to verify it Run on the switch and verify counters stats command and clear commands work correctly. After config reload or cold/fast reboot counters cache is removed. Signed-off-by: Stepan Blyschak <[email protected]>
- What I did To fix sonic-net/sonic-buildimage#9817. Cache all counters in the same place. Created a UserCache helper class to access the cache directory. - How I did it Implemented UserCache class. Changed all stats commands to use new class. Adopted fast-reboot script. - How to verify it Run on the switch and verify counters stats command and clear commands work correctly. After config reload or cold/fast reboot counters cache is removed. Signed-off-by: Stepan Blyschak <[email protected]>
A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location. - Why I did it To fix #9817. Clear the cache directory on swss.sh except for warm start. Also, adopted finalize-warmboot script to take the cache directory. - How I did it A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location. - How to verify it Run togather with sonic-net/sonic-utilities#2232. Verify counters cache is removed on config reload, cold/fast reboots, swss restart. Signed-off-by: Stepan Blyschak <[email protected]>
…-net#11244) A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location. - Why I did it To fix sonic-net#9817. Clear the cache directory on swss.sh except for warm start. Also, adopted finalize-warmboot script to take the cache directory. - How I did it A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location. - How to verify it Run togather with sonic-net/sonic-utilities#2232. Verify counters cache is removed on config reload, cold/fast reboots, swss restart. Signed-off-by: Stepan Blyschak <[email protected]>
- What I did To fix sonic-net/sonic-buildimage#9817. Cache all counters in the same place. Created a UserCache helper class to access the cache directory. - How I did it Implemented UserCache class. Changed all stats commands to use new class. Adopted fast-reboot script. - How to verify it Run on the switch and verify counters stats command and clear commands work correctly. After config reload or cold/fast reboot counters cache is removed. Signed-off-by: Stepan Blyschak <[email protected]>
- What I did To fix sonic-net/sonic-buildimage#9817. Cache all counters in the same place. Created a UserCache helper class to access the cache directory. - How I did it Implemented UserCache class. Changed all stats commands to use new class. Adopted fast-reboot script. - How to verify it Run on the switch and verify counters stats command and clear commands work correctly. After config reload or cold/fast reboot counters cache is removed. Signed-off-by: Stepan Blyschak <[email protected]>
Description
Steps to reproduce the issue:
The counter content is:
The content of admin user is like this (which imo is the correct value since we didn't clear counter on admin)
However, for root user the output is:
We observe the issue on 202012 but I think it should be reproduced on other branches as well.
Describe the results you received:
In
portstat
in step 5, all counter contains 0, which is wrong since traffic has been sent.Describe the results you expected:
In
portstat
in step 5, counters should contain the correct value.Output of
show version
:Output of
show techsupport
:Additional information you deem important (e.g. issue happens only occasionally):
In SONiC, the utilities like "portstat" show counter on a per-user basis especially after a user clears the counters.
It works like this: if a user clears counters, it caches the current values fetched from COUNTER_DB in the /tmp/ folder. Each time it is executed, it fetches the counters from COUNTER_DB, and then compares them with the cache, and then displays the difference.
Eg. the cached counter is 10, and the counter in COUNTER_DB is 15, it will display 5 which is 15 - 10.
However, when a user executes "config reload", the COUNTER_DB will be zeroed, which means the cached counter will be greater than the one fetched from COUNTER_DB. After that, the utilities can give wrong data.
sonic_dump_arc-mtbc-1001_20220120_151843.tar.gz
The text was updated successfully, but these errors were encountered: