With very, very rare exceptions when music is donated to a library, it just goes into the sale pile. I've had enormous trouble in the past few years donating valuable books to university libraries, i.e. things not in their collection but should be, and have basically given up. It truly was easier 10 or 15 years ago to donate massive collections of things. The one exception I am aware of here is the Merrill SF library will take donations of SF or fantasy books if not already in their collection. And the AGO Library will take art books. Those are pretty much the only exceptions I can think of.
In 20 years' time, I really don't think most music stores will be buying collections the way Jazz Record Mart or Amoeba do (or did) in the past. And with shipping prices going the way they are going, I can't imagine burdening someone with trying to sell it piecemeal through discogs...
If we downsize and move to a condo downtown or something when the last kid leaves the nest, I'll try to get rid of almost everything at that time. I barely listen to my physical collection at all anymore.
I'm in my late 50s and found a solution that worked for me a few years ago. When my ex-wife wanted a divorce (and I conceded), I moved out instead of fighting about who was going to keep the house. I decided at that time to split my collection in half. Mosaics and artists I loved, I would keep the physical Cds. The rest went to numerous public libraries around me (Boston). I know no one really thinks about libraries and they are going out of existence but I felt...
a) As long as public libraries exist, there will be people who use them and
b) If I'm lucky.. long after I'm gone., some teenager will run across my CDs and get the jazz bug.
Obviously, few of us rarely know when we are going to die, but I will probably tell my daughter to do the same when I'm gone.