We present evidence that the practice of holding back poorly performing students affects estimates of the impact of class size on student outcomes based on within-school variation of cohort size over time. This type of variation is commonly used to identify class size effects. We build a theoretical model in which cohort size is subject to random shocks and students whose performance falls below a threshold are retained. Our model predicts that initial birth cohort size is mechanically related to the grade-level share of previously retained students once these cohorts reach higher grades. This compositional effect gives rise to an upward bias in class size effects exploiting variation in birth cohort size. Using administrative data on school enrollment for all primary schools in one federal state of Germany, we find support for this compositional effect. Correcting for the resulting bias in a unique dataset on standardized test scores for the full student population of third graders, we find that not only are smaller classes beneficial for language and math test scores, but also for reducing grade repetition.