How to fix the "Unable to apply data patch Amasty\ShopbyBase\Setup\Patch\Data\AnchorRootCategories..." error?

How to fix the "Unable to apply data patch Amasty\ShopbyBase\Setup\Patch\Data\AnchorRootCategories..." error?

      According to the Shop by Brand code base, the extension checks the root categories on the Magento instance and makes them anchored. Due to some instance-specific factors, the process may fail resulting in the following error while running the bin setup:upgrade command: 
Unable to apply data patch Amasty\ShopbyBase\Setup\Patch\Data\AnchorRootCategories for module Amasty_ShopbyBase. Original exception message: Rolled back transaction has not been completed correctly 2

      If you face the issue in your environment, the following steps may help you to eliminate the problem.
      Step 1. Comment out the content of the "try" block in the Amasty\ShopbyBase\Setup\Patch\Data\AnchorRootCategories file:

      Step 2. After that, proceed to the Catalog → Categories and make sure the Root Category has Anchor parameter enabled.

      Step 3. Run the bin setup:upgrade command, it should complete smoothly this time. 
      Step 4. Once done, make sure to remove the comments from the lines you edited during Step 1.

      Should the issue persist in your environment, please, feel free to contact our support team for further investigation. 
      • Announcements

      • Already Done in Q1'23

        New features and improvements Order Attributes v3.8.0 NEW now Order Attributes are placed on the PayPal Review Page; we added compatibility with Hyvä Theme for the module. You can find package for installing in composer suggest (Note: the compatibility
      • Roadmap | What to expect in Q1'23

        New features and improvements Improved Layered Navigation generate SEO-friendly URLs for multi-select Category filter; better speed performance of the Apply filters button; improve Category list load time. Special Promotions Pro optimize data types in
      • Already Done in Q4'22

        New Amasty services Make sure your site is well-performing with our E-commerce QA testing service. Let our specialists check various elements of your website and get the issues fixed. The service is available for any e-commerce platform (Magento, Shopify,
      • Roadmap | What to expect in Q4'22

        New features and improvements Elastic Search better performance of synonyms; REST API support. Product Labels enhanced extension performance with a lot of products on the page. Blog Pro posts migration from one Magento instance to another; email notifications
      • Already done in Q3'22

        New solutions Our new SaaS tool - Website SEO Health Check. Discover the most severe SEO mistakes which can damage your website. Available as part of Pro and Premium SEO Toolkit. New features and improvements Import and Export NEW we added the possibility