-
Notifications
You must be signed in to change notification settings - Fork 264
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
RedisPipeline ignore flush when call dtor from another thread. #736
Conversation
@@ -7,6 +7,10 @@ | |||
#include "rediscommand.h" | |||
#include "dbconnector.h" | |||
|
|||
#include "unistd.h" | |||
#include "sys/syscall.h" | |||
#define gettid() syscall(SYS_gettid) |
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 is no wrapper for gettid() in glibc <= 2.30, so we need use syscall(SYS_gettid)
{ | ||
// call flush from different thread will trigger race condition issue. | ||
flush(); | ||
} |
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.
Fixed
@@ -19,10 +23,16 @@ class RedisPipeline { | |||
, m_remaining(0) | |||
{ | |||
m_db = db->newConnector(NEWCONNECTOR_TIMEOUT); | |||
initializeOwnerTid(); | |||
} | |||
|
|||
~RedisPipeline() { |
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.
No, I check all dtor in swss-common only find RedisPipeline class run redis command in dtor.
Do we need backport, for example to 202012 branch? |
…-net#736) #### Why I did it Because RedisPipeline is not thread safe, in c++ if code call exit() from another thread, the dtor of RedisPipeline will be called from another thread and trigger a race condition issue. #### How I did it RedisPipeline ignore flush when call dtor from another thread. #### How to verify it Pass all UT and E2E test cases. #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 #### Description for the changelog RedisPipeline ignore flush when call dtor from another thread. #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/SONiC/wiki/Configuration. --> #### A picture of a cute animal (not mandatory but encouraged)
Update sonic-swss-common submodule pointer to include the following: * 6b6842a [NotificationProducer] add pipeline support ([sonic-net#708](sonic-net/sonic-swss-common#708)) * 2cb5ea0 Increase the netlink buffer size from 3MB to 16MB. ([sonic-net#739](sonic-net/sonic-swss-common#739)) * dacbdad RedisPipeline ignore flush when call dtor from another thread. ([sonic-net#736](sonic-net/sonic-swss-common#736)) Signed-off-by: dprital <drorp@nvidia.com>
Update sonic-swss-common submodule pointer to include the following: * 6b6842a [NotificationProducer] add pipeline support ([#708](sonic-net/sonic-swss-common#708)) * 2cb5ea0 Increase the netlink buffer size from 3MB to 16MB. ([#739](sonic-net/sonic-swss-common#739)) * dacbdad RedisPipeline ignore flush when call dtor from another thread. ([#736](sonic-net/sonic-swss-common#736)) Signed-off-by: dprital <drorp@nvidia.com>
#### Why I did it Because RedisPipeline is not thread safe, in c++ if code call exit() from another thread, the dtor of RedisPipeline will be called from another thread and trigger a race condition issue. #### How I did it RedisPipeline ignore flush when call dtor from another thread. #### How to verify it Pass all UT and E2E test cases. #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 #### Description for the changelog RedisPipeline ignore flush when call dtor from another thread. #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/SONiC/wiki/Configuration. --> #### A picture of a cute animal (not mandatory but encouraged)
Why I did it
Because RedisPipeline is not thread safe, in c++ if code call exit() from another thread, the dtor of RedisPipeline will be called from another thread and trigger a race condition issue.
How I did it
RedisPipeline ignore flush when call dtor from another thread.
How to verify it
Pass all UT and E2E test cases.
Which release branch to backport (provide reason below if selected)
Description for the changelog
RedisPipeline ignore flush when call dtor from another thread.
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)