The actual sole is sewn to the insole, by hand or a machine. Then you attach the final layer(s) to this construction, who builds up the basement.
So, if you do not have a cobbler on hand, who is familiar with this technique, he can remove the pegged layer, grounds down the pegs and helps himself out with a glue job.
On one of my shoes, the pegs loosened a bit(after 12 years). They had a aftermarket rubber sole installed. I tested this version, but didn't like. So I was intended to wear the rubber down etc., etc..
In this case we had to decide, if i will do a full repair, what would have required, doing the pegs, twice on the damaged shoe. This is not cost effective and more of a cosmetic touch for the final result.
So, we decided on the interim
solution. Doing the glue job now, and a full refurbish later.
Hope this helps.