I just completed parsing the Testnet3 Bitcoin blockchain stored in the blk.dat files into a database. Since I was using multi-processing to parse several files at the same time, I didn't add the height to the blockchain while parsing it. Instead, I did this after the whole blockchain was parsed.
Everything was going smoothly while adding the height to the blocks for the most part. However, approaching the end of the blockchain (the last 7%), my code started to crash because it started to find 2 different blocks that had the same previous block (basically, a fork), and I had already constrained my database to avoid having 2 blocks with the same height. All these tiny forks I have been finding are just one block long, and it looks like the closer I get to the end, the most common it is to find these tiny forks.
I have had to look both block-ids up in a block explorer to find out which one is the official block and which one is the fork ("fake" block). One of them is always non-existent for which I know it is not an ID misplacing. I have been manually deleting the link of the "fake" block so my code can keep adding the height, but as I said before, it becomes more and more common to find these tiny forks the more I approach the end of the blockchain.
I was just wondering if this is normal, or if there is something really wrong with my blk.dat files.