It may not be the police's fault that the licence showed as being invalid, but the police should definitely have been aware that administrative mistakes by the DVLA in this area can and do regularly happen. They should not have just taken it as gospel that because the licence was not on their system, it must be invalid.
Imagine the OP's licence really is valid all along, which it may well be if DVLA incompetences are anything to go by. Then what do you think of the way the police allegedly acted according the OP's description?
This one sentence sums up the situation perfectly. Yes, we
all know that the DVLA makes mistakes and, because the police deal with the DVLA on a regular basis, they too
must be patently aware of the shortcomings to which the DVLA is prone.
If the OP's description of events is true, then the police made the mistake of
assuming the OP was acting illegally, without any consideration for the fact that they know the DVLA makes mistakes. In so doing, the police have taken on board full responsibility for their actions, and therefore
must accept the liability for the distress and costs they have caused by their rash treatment of an innocent citizen.