Drawing from Lovell’s “The Opium War”, I can answer your question for Qing-era China (ca. 19th century AD).
Theoretically, China was an enlightened Confucian meritocracy. The intellectuals of the empire would spend years studying Confucianism, which taught them everything they needed to know. Then an assessment would determine the best-and-the-brightest among them, who would then become civil servants. Among civil servants, you could again advance through a more difficult assessment towards positions of higher responsibility. Thorough education and objective assessment would root out favoritism and incompetence, handing the government to those who would best care for it. This might be termed a meritocracy, yes. At least that was the theory.
In practice, Qing China was a rotten place.
The problems start with Confucianism itself. Confucianism might be a nice paradigm, but is not exactly teaching practical governance skills and pragmatism. A rough analogy would be if applying civil servants in the US had to write a long essay on the Founding Fathers’ Awesomeness. It just does not directly contribute to your later job.
Also, Confucianism held merchants in very low regard, claiming that they were unnecessary or parasitic. This meant that highborn youths were funneled into just one career path: civil servant. And here the system really fell to pieces. After fanatically studying Confucianism since earliest childhood, a young aspiring Chinese graduate would go to the assessment and find out that there were about 100 applicants for 1 open position at the only possible employer nationwide (the government). I am serious and this is not sarcastic exaggeration. The number given by Lovell is that 1.5% of applicants passed the assessment and were hired, but she adds that China’s population was increasing faster than its administrative positions, making the odds even worse as time progressed. Many Chinese would spend their entire life, applying, applying, applying, applying, applying, … without ever being hired. But there was just no way out. You cannot become a landholder, because land is scarce, nor a craftsman as this is beneath you, merchants are bad, the army isn’t for everyone, … The vast majority of highborn Chinese were doomed for a life as an perpetual applicant and “academic failure”.
In Qing China, what made this even worse was ethnic favoritism. Applicants from the Emperors ethnic group (the Manchu, a nomad tribe from the north of China that had conquered the empire and then adopted its customs) would get preferential treatment during the (supposedly fair) assessment, thus decreasing the odds for other Chinese even further.
The jobs were rewarding, but they needed to be. The entire family might depend on one heroic scion to support them all, while they themselves were busy studying for the next assessment. In this situation, it is obvious that no matter what Confucianism preached, corruption would inevitably creep up among the happy select few in public positions. They needed to support their clan, maybe even repay its debt, sometimes for several generations before the next scion got hired.
The situation fostered civil servants eager to cash in their reward or, curiously, fanatical crusaders against transgressions against an inflexible Confucian doctrine. As well as generations of men who were left in a state of unemployment.