I see a bunch of methods on ILoadBalancer that return a database connection:
- getAnyOpenConnection
- getConnection
- getServerConnection
- getConnectionRef
- getLazyConnectionRef
- getMaintenanceConnectionRef
Whenever I want to replace a wfGetDB() with DI, I'm not sure which to use. getAnyOpenConnection() sounds scary, and getServerConnection() is clearly not what I want, but from reading the comments, I can't figure out the difference between the others. getConnection() is the obvious choice, but I don't know what the "Ref" does. "Lazy" sounds good if I might not use it right away, but there must be some reason why we don't always return a lazy connection, so I don't know what kind of cost I'm paying. I have no idea what "Maintenance" is supposed to mean, and the documentation points me away from using it ("that can be used for data migrations and schema changes"), but that's what wfGetDB() actually uses, so surely it's the safest choice.
In short, please add some explanation here that's helpful for end-users who don't understand the details of our database setup. :) I just now saw buried in the middle of the class comment that "The typical caller will use LoadBalancer::getConnection( DB_* )", but I still don't know if I'm potentially causing behavior changes by switching from wfGetDB() (= getMaintenanceConnectionRef) to that, nor when I'm atypical and should use the other methods.