Subnet options are not being loaded from the config database for all subnets
When we use SQL to fetch subnets from CB back end each row consists of data from subnet table joined with pools, options and so forth. These rows are ordered by the clause "s.subnet_id, p.id, x.option_id, o.option_id". We keep track of last subnet id, last pool id, last option id to decide when we have reached a new object.
Each time we start a new subnet, (i.e. last subnet id is less than the current on), we should zero out all tracking variables such as last_pool_id, last_option_id etc but we are not. We are currently only zeroing out last_pool_id.
Thus when you load a subnet which recently added a new option, that option will have a relatively high option id and this value becomes last_option_id. This will cause subsequent subnets being fetched to discard their options as the option ids are always less than last_option_id. Fetching subnets individual subnets per CB commands still works properly IF you do not fetch subnets with low subnet IDs but high option IDs.
The issue was reported under support ticket https://support.isc.org/Ticket/Display.html?id=15872
The conceptual (but incomplete) fix is pretty simple and is attached: