Me also, where my regular non-pinned tabs were still available in history, but all the pinned tabs are totally gone and cannot be found in history, and they no longer populate when I open a new window.
This had happened to me the same way as you described, after reopening my closed window using "History - Reopen Last Closed Window". The link (of how I recovered the pinned tabs via Time Machine) was just removed by moderators. The linked method is necessary to recover the pinned tabs if you have Safari 17 MacOs 14.6, maybe also Safari 16 according to reddit; others in the same situation can do their own web search, because these are the files that have to be restored from a date/time before the pinned tabs disappeared:
CloudTabs.db
CloudTabs.db-shm
CloudTabs.db-wal
SafariTabs.db
SafariTabs.db-shm
SafariTabs.db-wal
Afterwards, the older, restored version of Safari looks like it should, with the pinned tabs in every opened window. I saved each pinned tab on to my reading list (remember to make reading list available offline.)
But I also need the most recent Safari browsing history that occurred after the rescued TimeMachine date/time that I used to find and restore the pinned tabs. So then I used Time Machine to change those 6 files to the most recent time, so the pinned tabs are missing again, but now they are saved in my reading list, where I am bookmarking them into Favorites.