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

[logger] Make map access thread safe and proper terminate thread #510

Merged
merged 3 commits into from
Aug 20, 2021

Conversation

kcudnik
Copy link
Contributor

@kcudnik kcudnik commented Jul 24, 2021

Signed-off-by: kcudnik [email protected]

Fixes sonic-net/sonic-buildimage#8177

I also made some minor code style refactoring

@kcudnik
Copy link
Contributor Author

kcudnik commented Jul 25, 2021

test error on test_ConfigDBSubscribe not related to PR

@kcudnik
Copy link
Contributor Author

kcudnik commented Jul 25, 2021

@arlakshm can you check this test_ConfigDBSubscribe ?


m_settingThread = nullptr;

m_runSettingThread = true;

Choose a reason for hiding this comment

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

Might consider putting m_runSettingThread = true; in restartSettingThread? Not sure which is cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to restart

Comment on lines 254 to 255

m_settingChangeObservers.get(key).first(key, value);

Choose a reason for hiding this comment

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

nit: extra blank line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove

linkToDb(dbName, swssPrioNotify, defPrio);
logger.m_settingThread.reset(new std::thread(&Logger::settingThread, &logger));

getInstance().restartSettingThread();

Choose a reason for hiding this comment

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

Is restarting the thread actually required if the thread is already started and the data structures are thread-safe? Put another way: is there any reason to maintain a separate linkToDbNative and linkToDb vs consolidating them into one function which starts the thread if needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thats a good question, im just fixing this instance here, since previously if you call linkToDbNative twice, it will crash, and whether we should have only 1 thread, not sure about that, this PR is just to make those maps thread safe + plus crahs bug fix not changing behavior, @qiluo-msft can you have opinion?

@kcudnik kcudnik requested a review from lguohan August 4, 2021 10:13
@kcudnik
Copy link
Contributor Author

kcudnik commented Aug 4, 2021

ping

mikeberesford
mikeberesford previously approved these changes Aug 5, 2021
namespace swss
{
template <typename K, typename V>
class ConcurentMap

Choose a reason for hiding this comment

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

nit: typo (ConcurrentMap)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@kcudnik
Copy link
Contributor Author

kcudnik commented Aug 9, 2021

ping

1 similar comment
@kcudnik
Copy link
Contributor Author

kcudnik commented Aug 17, 2021

ping

@kcudnik kcudnik merged commit 9fd7dbf into sonic-net:master Aug 20, 2021
@kcudnik kcudnik deleted the mapfix branch August 20, 2021 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

occasional syncd crash at initialization time
3 participants