Skip to content

MySQL IDO prematurely logs "Finished reconnecting" #10327

Open
@Al2Klimov

Description

Describe the bug

At least IdoMysqlConnection#Reconnect():

  1. calls UpdateAllObjects()
    • UpdateAllObjects() puts lots of stuff in m_QueryQueue
  2. 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): fe85bf1
  • 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".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions