magento2 – M2: all quotes remain active – where should they be set inactive?

M2.3.3: We have a situation where all quotes remain active (i.e. is_active=1). That means they’re never cleared by cron as that only clears inactive quotes.

We now have ~186k quotes in the database, going back to when the site was first setup. 185k have no customer id; around 900 have a customer id. As the store is B2B and only open to logged in customers (no guests), how can we end up with the majority of quotes having no customer (customer_id=NULL)? Only thing that I can think is Magento is creating a quote for every single visitor, before they logon. Assume the customer gets another quote when they logon, leaving these “guest” quotes active so they’re never cleared. None are persistent (that’s off).

Seems to me the quote clean-up routine is not fit for purpose.

However, clearly there’s something seriously awry with how quotes are converted to orders. Appears that in our checkout process, quotes generating orders are never being set inactive. I’ve tried to trace how the quote gets set inactive during the order flow, but nothing jumps out in the code to suggest where this should happen.

Does anyone know what part of the order process (i.e. code) is supposed to set the quote that generated it to inactive?