How to deal with unavoidable failure in my first year of tenure-track applications? I got my PhD recently. I applied to many tenure-track positions and got selected for several onsite job interviews. Yay. However I have actually been told in no uncertain terms by several trusted people that this year, my chances are extremely close to zero, considering my short track record.

I cannot help but get my hopes up. How do I deal with this upcoming unavoidable failure and put a good spin for myself on my situation?

It may sound stupid but like many people in academia, so far I have been quite successful and have not had to deal with professional failure much... (Consider this: good in school, good in university, graduated with honors, got accepted to masters, got accepted to PhD, got the PhD - most people in academia follow this kind of path. I hope this does not come across as immodest, I am very aware that I am just a cog in the grand (grant?) scheme of academia. I am good at what I do but not at the rest.) Of course I met failure very often in my private life, but this does not feel the same.
I suggest dealing with the situation by revising your (misguided, IMO) definition of “failure”. Even if it is, as you say, “ineluctable”, that you will fail to land a tenure-track position this year, you will still be a highly qualified and highly successful person with excellent career prospects. To refer to this as a failure is itself a failure - a failure of the imagination, that is.

I and most other successful academics had to spend multiple years after graduation to get a good tenure-track position. Almost all of us struggled with repeated rejections, job uncertainty, and geographic dislocation before arriving at a good place career-wise. Keep your eyes focused on your long-term goals and on the fun and passion of doing research, and given your description of your situation I predict that you will be fine. Regardless of what happens with your current job search, a “failure” you most certainly are not.