I have a computer I use for imaging disks running Ubuntu 16.04. Each disk is inserted into a USB 3.0 dock, imaged/wiped, and then disconnected. The disks don't have any mounted filesystems which need to be dismounted. They disappear from gnome-disks as expected. Eventually, using gparted and/or the gnome-disks, I am no longer able to see any new disks that get added. Sometimes, new disks show up under an old /dev/sdx device and I can access them but they show the old device's partition table and size. I assume this is because /dev/sdx is filling up and the kernel is holding onto pointers to disks which no longer exist?
Edit: I should add that a number of these disks have bad sectors or other issues, so that could be a part of the problem as well. This "block device exhaustion" happens faster when more malfunctioning drives are added/removed. Once it happens, even good drives won't appear when added to the system. But I notice this happens even if all drives I'm adding/removing are healthy and functioning.
What can I do to prevent this behaviour or tell the kernel to "forget" disconnected disks?