laravel-scout-tntsearch-driver icon indicating copy to clipboard operation
laravel-scout-tntsearch-driver copied to clipboard

11 database disk image is malformed

Open MathiasWeisheit opened this issue 3 years ago • 9 comments

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?

MathiasWeisheit avatar Apr 19 '21 10:04 MathiasWeisheit

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

nticaric avatar Apr 19 '21 11:04 nticaric

How can I prevent multiple workers on unit tests?

MathiasWeisheit avatar Apr 19 '21 11:04 MathiasWeisheit

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?

nticaric avatar Apr 19 '21 11:04 nticaric

The other option is disabling queues for unit tests, which you can do in scout.php

nticaric avatar Apr 19 '21 11:04 nticaric

I'll check it

MathiasWeisheit avatar Apr 19 '21 12:04 MathiasWeisheit

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)

MathiasWeisheit avatar Apr 20 '21 07:04 MathiasWeisheit

'queue' => env('APP_ENV') == 'testing' ? false : env('SCOUT_QUEUE', false),

MathiasWeisheit avatar Apr 20 '21 07:04 MathiasWeisheit

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

nticaric avatar Apr 20 '21 08:04 nticaric

Since you are using Scout with TNTSearch, you might also check out our new analytics package, but of course, you don't have to

nticaric avatar Apr 20 '21 08:04 nticaric