laravel-scout-tntsearch-driver
laravel-scout-tntsearch-driver copied to clipboard
11 database disk image is malformed
Hi,
I have a problem with TNTIndexer within my software tests. Adding the searcheable model "product" forces this problem:
PDOException: SQLSTATE[HY000]: General error: 11 database disk image is malformed
/app/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:685 /app/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:424 /app/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:405 /app/vendor/teamtnt/laravel-scout-tntsearch-driver/src/Engines/TNTSearchEngine.php:66 /app/vendor/laravel/framework/src/Illuminate/Support/Traits/EnumeratesValues.php:202 /app/vendor/teamtnt/laravel-scout-tntsearch-driver/src/Engines/TNTSearchEngine.php:70 /app/vendor/laravel/scout/src/Jobs/MakeSearchable.php:42
I removed the trait Laravel\Scout\Searchable --> it works I removed the toSearchableArray function --> it works
With both of them, the error occures in /app/vendor/teamtnt/tntsearch/src/Indexer/TNTIndexer.php:685 ...
What can I do?
How many queue workers do you have running? If multiple workers are trying to write to a single db file, this might cause this issue
How can I prevent multiple workers on unit tests?
Can you tell us more about your setup. Who is running those unit tests and how? Are they run in parallel? Is everything going to the default queue, or do you have a special queue created only for search?
The other option is disabling queues for unit tests, which you can do in scout.php
I'll check it
Hi, in my .env these variables are set:
SCOUT_DRIVER=tntsearch
SCOUT_QUEUE=true
So I would change the 'queue' => env('SCOUT_QUEUE', false), in scout.php to check the environment?
'queue' => env('APP_ENV', 'testing') ? false : env('SCOUT_QUEUE', false)
'queue' => env('APP_ENV') == 'testing' ? false : env('SCOUT_QUEUE', false),
In principle yes, you would change it like this. But the more elegant approach would be not to pollute the config file with if statements.
For example.
//config/scout.php
'queue' => env('SCOUT_QUEUE', false),
For testing, you simply create a new .env.testing
file, which has
SCOUT_QUEUE=false
Since you are using Scout with TNTSearch, you might also check out our new analytics package, but of course, you don't have to