Skip to content

RedisConnection#Connect(): get rid of spin lock#10265

Merged
julianbrost merged 3 commits intomasterfrom
RedisConnection-spinlock
May 14, 2025
Merged

RedisConnection#Connect(): get rid of spin lock#10265
julianbrost merged 3 commits intomasterfrom
RedisConnection-spinlock

Conversation

@Al2Klimov
Copy link
Copy Markdown
Member

@Al2Klimov Al2Klimov commented Dec 6, 2024

Instead of IoEngine::YieldCurrentCoroutine(yc) until m_Queues.FutureResponseActions.empty(), async-wait a CV which is updated along with m_Queues.FutureResponseActions.

👍 Re-connect still works on Redis restart, even if latter interrupted an outgoing message!

[2024-12-06 10:24:02 +0100] critical/IcingaDB: Error during sending query 'XADD' 'icinga:stats' 'MAXLEN' '1' '*' 'ApiListener' '{"perfdata":[{"counter":false,"crit":null,"label":"api_num_co...' ... which has been fired and forgotten: Broken pipe
[2024-12-06 10:24:02 +0100] information/IcingaDB: Connected to Redis server

ref/NC/820479
claimed they start Icinga 2 with Icinga DB enabled – and it OOMs. I hope this spin lock is not responsible, but better safe than sorry.

Also, I'm sure we all agree that spin locks should be avoided, at least where easily possible.

@Al2Klimov Al2Klimov added area/icingadb New backend core/quality Improve code, libraries, algorithms, inline docs labels Dec 6, 2024
@cla-bot cla-bot bot added the cla/signed label Dec 6, 2024
@Al2Klimov Al2Klimov requested a review from yhabteab December 16, 2024 11:33
@yhabteab yhabteab added this to the 2.15.0 milestone Jan 13, 2025
@Al2Klimov Al2Klimov removed this from the 2.15.0 milestone Jan 21, 2025
@Al2Klimov Al2Klimov force-pushed the RedisConnection-spinlock branch from c0dd426 to fd24514 Compare January 29, 2025 16:31

/**
* Condition variable which doesn't block I/O threads
* Awaitable flag which doesn't block I/O threads, inspired by threading.Event from Python
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Please see the updated docs of the class in question.

@Al2Klimov Al2Klimov added this to the 2.15.0 milestone Mar 18, 2025
@Al2Klimov Al2Klimov requested a review from yhabteab March 18, 2025 10:50
The current implementation is rather similar to Python's threading.Event, than to a CV.
@Al2Klimov Al2Klimov force-pushed the RedisConnection-spinlock branch from fd24514 to d54be97 Compare April 30, 2025 15:33
@Al2Klimov Al2Klimov force-pushed the RedisConnection-spinlock branch 2 times, most recently from ecbcdcb to b4631ba Compare May 14, 2025 09:21
Al2Klimov added 2 commits May 14, 2025 12:24
Instead of IoEngine::YieldCurrentCoroutine(yc) until m_Queues.FutureResponseActions.empty(), async-wait a CV which is updated along with m_Queues.FutureResponseActions.
@Al2Klimov Al2Klimov force-pushed the RedisConnection-spinlock branch from b4631ba to 2739f7f Compare May 14, 2025 10:28
Copy link
Copy Markdown
Member

@yhabteab yhabteab left a comment

Choose a reason for hiding this comment

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

LFTM!

@julianbrost julianbrost merged commit 1a386ad into master May 14, 2025
26 checks passed
@julianbrost julianbrost deleted the RedisConnection-spinlock branch May 14, 2025 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/icingadb New backend cla/signed core/quality Improve code, libraries, algorithms, inline docs ref/NC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants