The word had can easily appear twice consecutively in a sentence, for example “The opinion he had had didn’t matter“. Three times is quite possible “The opinion he had had had no effect“, and even four times “The opinion he had had had had no effect“, but I recently came across a sentence with eleven consecutive had

It’s not really a true tongue-twister, but it actually is a meaningful sentence

Twister

Explained in this Wikipedia article, the sentence is: “James while John had had had had had had had had had had had a better effect on the teacher“.

It clearly requires an explanation, that is provided in the article, and makes sense:

The [sentence] refers to two students, James and John, who are required by an English test to describe a man who, in the past, had suffered from a cold. John writes “The man had a cold“, which the teacher marks as being incorrect, while James writes the correct “The man had had a cold.” Since James’ answer was right, it had had a better effect on the teacher.

The sentence can be understood more clearly by adding punctuation and emphasis:

James, while John had had “had”, had had “had had”; “had had” had had a better effect on the teacher.