You can check the status of your ElasticSearch running this command below in your server.
curl -XGET 'http://localhost:9200/_cat/nodes?v'
As you can see the normal is 60% of usage, if your heap size needs to be increased, you will see high usage of it.
It depends on how many threads you have in your server, to check if you can run this command below.
You will see something like this:
Then you can test as I did below, you will see that you can run the reindex process much faster allowing it to run with more threads allocated to it.
MAGE_INDEXER_THREADS_COUNT=$(nproc) php -f bin/magento indexer:...
This is a permission issue and you can fix it just running the below command.
It will work but you need to give permission every time.
sudo chmod -R 777 var/;sudo chmod -R 777 pub/;sudo chmod -R 777 generated/;
Perfect solution - need to give one time permission
You need to do the following stuff:
First You need to change the mode of indexing to Update on Save by using this command
php bin/magento indexer:set-mode realtime
After that you need to reset the indexing
php bin/magento indexer:reset
After that truncate _cl tables related to your issue occuring indexing
After that reindex the indexing
php bin/magento ...
For me the cataloginventory_stock_item & quote_item tables were the offending ones here. Somehow customers with old carts were able to checkout with products that didn't exist. Something to do with their old Magento 1 migration to Magento 2 I think. I tweaked the above query from @Ward like so:
DELETE FROM ...