No matter how you slice it, this strategy can only be a temporary measure, no matter what you fill it with, or how deep the canal. Zombies have infinite patience and tenacity. Every second of every day they will be honed in on whatever most captures their attention. From a practical perspective, you can consider the number of zombies as infinite, but any moat or ditch is finite, by definition. We all know that ∞ > any finite quantity. Unless your protagonist is very old, we're talking about a time scale of decades.
A huge writhing pile of groaning zombies is likely to attract even more groaning, writhing zombies. Light sources in your castle will attract them. Dislodged stonework falling from your keep will attract them. Dead animals will attract them. Your huge castle will require maintenance and upkeep after some time. Things rust, mortar loosens, treated wood will eventually develop cracks, allowing moisture and rot. And what will you do with all of your personal waste? You won't be able to hide human activity forever.
Given enough time, they will make it over or through, unless you can provide for a chasm that is thousands of feet deep.
You'll also need to consider the disease, pestilence and odor that will come off these zombies. It wouldn't take long for conditions in the immediate area to become unlivable, unless your trench is significantly distant from your castle (I would assume > 1 mile). All of the land surrounding the trench would be polluted and ruined. The groundwater would become toxic. The fallow and rotten ground would encroach little by little on your castle property.
Even the strategy of locking the door and never leaving will fail eventually. Unlike the way zombies are depicted on TV (and played by living human actors), zombies will have no sense whatsoever of personal space. They will care not about broken bones, cracked skulls, dripping entrails or any other bodily damage. As they begin finding their way to your castle wall, they will compress into each other as they bunch up against the wall. In fact, long before they find your walls, some zombies will be clumped into shambling clots of rotten, fetid, mindless animation. Over time, some of those rot-melded herds will be hundreds or thousands in size.
Eventually, as individual and clumped zombies make their way to your walls, the front lines would be pressed into splattery ichor. Over time, there will be tremendous sustained pressure against your aging castle walls. What happens when they find a soft spot? And the crushed zombies will begin forming into a pile, slowly, but eventually rising over time. They don't care how many years it takes.
A slowly growing pile of rotten and rotting flesh, right up against your castle walls.
This would be repulsive and toxic to humans, but there are certainly animals who would be attracted to this, and from many miles away. Vultures, coyotes, hawks, and nearly any starving animal will take an interest. And maggots by the ton. All of which would continue to attract zombies.
On the bright side - butterflies!
Edit:
Since I don't have enough rep yet to upvote or post a comment, I just wanted to "upvote" Rathgill's answer and say thanks for quantifying the enormity of zombies! While it is true that there wouldn't literally be an infinite number of zombies, I was hoping it would be implicit that I meant that, from a lone survivor's perspective, the inexhaustible supply would be equivalent to an infinite supply over the source of their lifetime.