Opened 4 years ago

Closed 4 years ago

#4544 closed defect (fixed)

DB Access Parser must recreate HostMgr rather than call HostDataSourceFactory

Reported by: marcin Owned by: marcin
Priority: medium Milestone: Kea1.1
Component: host-reservations Version: git
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: High
Sub-Project: DHCP Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 1
Total Hours: 1 Internal?: no


The following thread: contains a bug report whereby Kea fails to allocate reserved address from MySQL database.

The issue appears to be a result of Kea closing connection to the database during processing client's packet. Because the connection gets close, Kea server never gets round to checking if the particular client has any reservations.

Why Kea closes database connection?
The CfgDbAccess::createManagers function calls HostDataSourceFactory::create during initial configuration of the server. The database connection gets opened. The client sends a packet and the server at some point calls AllocEngine::findReservation to retrieve reservations for this client. This in turn calls HostMgr::instance().get4(...). At this point the HostMgr::instance() is called for the first time. Because of the lazy initialization, it checks that the pointer to the HostMgr doesn't exist, so it calls HostMgr::create() (with no parameters). Because parameters aren't present, the HostDataSourceFactory::destroy is called and it tosses existing connection to MySQL database.

The proposed fix for this is to replace a call to HostDataSourceFactory::create(...) within CfgDbAccess::createManagers with HostMgr::create() which should reinitialize the HostMgr and also the associated alternate source.


Change History (6)

comment:1 Changed 4 years ago by tomek

  • Milestone changed from Kea-proposed to Kea1.1

Accepting to 1.1 as medium per 2016-07-28 call.

comment:2 Changed 4 years ago by marcin

  • Owner set to marcin
  • Status changed from new to accepted

comment:3 Changed 4 years ago by marcin

  • Owner changed from marcin to UnAssigned
  • Status changed from accepted to reviewing

Fix is ready. Proposed ChangeLog entry:

11XX.	[bug]		marcin
	Corrected a bug whereby clients were not assigned reserved
	addresses from an external database, as a result of unexpected
	closure of a connection to that database.
	(Trac #4544, git abcd)

comment:4 Changed 4 years ago by tomek

  • Owner changed from UnAssigned to tomek

comment:5 Changed 4 years ago by tomek

  • Add Hours to Ticket changed from 0 to 1
  • Owner changed from tomek to marcin
  • Total Hours changed from 0 to 1

I have reviewed the changes and they look good. All unit-tests pass on Ubuntu 16.04 x64 with MySQL support enabled. Please merge.

comment:6 Changed 4 years ago by marcin

  • Resolution set to fixed
  • Status changed from reviewing to closed

Merged with commit 7f682112dd5ab9fcd6bfa4e10505c246775f353d

Note: See TracTickets for help on using tickets.