Agents-in-DB: add multiple masters support