MySQL IDO prematurely logs "Finished reconnecting"
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 616
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 10
Description
Describe the bug
At least IdoMysqlConnection#Reconnect():
- calls UpdateAllObjects()
- UpdateAllObjects() puts lots of stuff in m_QueryQueue
- puts a callback in m_QueryQueue
- that callback logs "Finished reconnecting"
So at least the MySQL IDO fires all initial queries and then logs "Finished reconnecting" – right? Wrong!
The MySQL IDO indeed TRIES to fire those queries before logging "Finished reconnecting". But if any of them yet misses an ID of a parent object (which is to be inserted by a query not fired yet), it lands again in m_QueryQueue AFTER logging "Finished reconnecting".
To Reproduce
- Kick off a full dump (empty DB) of a bunch of hosts + services + notifications, etc.
- Watch number of pending queries and "Finished reconnecting"
Expected behavior
Either – or:
- (Simple solution) IdoMysqlConnection#Reconnect() puts a callback in m_QueryQueue which puts a callback in m_QueryQueue which logs "Finished reconnecting"
- (Less simple solution) "Finished reconnecting" callback checks whether all items from DbConnection#UpdateAllObjects() are done (atomic counter needed), otherwise it re-enqueues itself
- (Least simple solution) Putting a callback in m_QueryQueue which logs "Finished reconnecting" happens not directly in IdoMysqlConnection#Reconnect(), but in a Shared<Defer> – all m_QueryQueue items from DbConnection#UpdateAllObjects() hold pointers to that Defer
Your Environment
- Version used (
icinga2 --version): fe85bf12952ef193f994506f3fe5117258e71c07 - Operating System and version: any
- Enabled features (
icinga2 feature list): ido-mysql
Additional context
One shouldn't need the above insider knowledge to know when the IDO actually "Finished reconnecting".
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with IdoMysqlConnection#Reconnect(), DbConnection#UpdateAllObjects(), and the m_QueryQueue handling described in the issue. Trace how queued callbacks and dependent queries are processed, then verify that "Finished reconnecting" is logged only after the initial update work and any re-enqueued queries are complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, mysql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100