def METHOD_NAME(
    model: Union[Type[ControlOutboxProducingModel], Type[RegionOutboxProducingModel]],
    *,
    batch_size: int,
) -> BackfillBatch | None:
    lower, version = get_processing_state(model._meta.db_table)
    if version > model.replication_version:
        return None
    if version < model.replication_version:
        lower = 0
        version = model.replication_version
    upper = model.objects.aggregate(Max("id"))["id__max"] or 0
    batch_upper = min(upper, lower + batch_size)
    # cap to batch size so that query timeouts don't get us.
    capped = upper
    if upper >= batch_upper:
        capped = batch_upper
    return BackfillBatch(low=lower, up=capped, version=version, has_more=upper > capped)