To repair a Photos library you select the library in the Finder. Then hold down the key combination option-command while you double click the library to open it.
Keep holding down both keys firmly, until the repair dialog appears.
but before trying to do that, make a backup copy of the library, without overwriting an older backup. You may need any older backup to restore your library.
and check first, if your Photos Library is stored on a correctly formatted drive, if you are not keeping it in your Pictures folder. A Photos Library can get corrupted beyond repair, if it is on an external drive that is used by Time Machine, or is not formatted Mac OS Extended. The drive needs to have a wired connection And not a network connection. The library must not be in a cloud storage - Dropbox or iCloud drive or goole drive.
Also, have you been running any cleaning software to remove duplicates? Some applications are dangerous.