Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行 addtoindex 命令报错 InvalidArgumentException #7

Open
cnych opened this issue Feb 24, 2022 · 17 comments
Open

执行 addtoindex 命令报错 InvalidArgumentException #7

cnych opened this issue Feb 24, 2022 · 17 comments

Comments

@cnych
Copy link

cnych commented Feb 24, 2022

php flarum sonic:addtoindex
Starting...
Flush old postCollection: 1
Adding to index...

In Ingest.php line 63:

[InvalidArgumentException]

sonic:addtoindex

sonic 1.3.2 版本,flarum 1.2.0 版本

@ganuonglachanh
Copy link
Owner

Did you do the step 3 Change info in admin setting before run this command?

@cnych
Copy link
Author

cnych commented Feb 26, 2022

@ganuonglachanh 配置了的

image

因为我这里是跑在k8s里面的,所以需要修改下host地址

@ganuonglachanh
Copy link
Owner

If you're sure the host is correct, does the password is same as the default (SecretPassword)?

P/S: and if you're using Chinese, locale should not be "eng" (an ISO 639-3 locale code eg. eng for English)

If alls above info is correct, please send you detail setup info :)

@cnych
Copy link
Author

cnych commented Feb 27, 2022

@ganuonglachanh 中文的话 locale code 应该设置成多少?zho?不对,用默认的 eng 在 Sonic 这边是可以生成一部分索引的,只是不全~

Ingest.php 这个文件是在什么地方呢?没有找到

@ganuonglachanh
Copy link
Owner

Sonic locale code for Chinese should be "cmn"

https://github.com/ppshobi/psonic/blob/master/src/Ingest.php

Please send you detail setup info for futher investigation and could you please use English for conversation?

@cnych
Copy link
Author

cnych commented Mar 6, 2022

Sorry!

  • first I use valeriansaliou/sonic:v1.3.2 docker image in kubernetes
  • then install sonic plugin in flarum use composer require ganuonglachanh/sonic command
  • then enable it in admin setting
  • back to flarum terminal do php flarum sonic:addtoindex command. Finally got the error mentioned above!

3Q

@ganuonglachanh
Copy link
Owner

Thanks, I tested with valeriansaliou/sonic:v1.3.2 with no error.

Is your flarum install is test data? Could you send me the exported database of test flarum?

If you couldn't provide database, what is your charset and collation setting in flarum config.php ?

You can try to debug the content that have error by adding this code to the line 69 of src/Console/AddToIndex.php

echo $post->content . PHP_EOL;

then rerun the php flarum sonic:addtoindex command

@lihaorr
Copy link

lihaorr commented May 27, 2022

image

Hello, I encountered the same problem, I did the debugging according to your meaning, and the content of one of my articles appeared above the console error. Also I have set the “cmn”

thx!

@tansongchen
Copy link

Same problem here. I couldn't provide the database but I can share the config in config.php:

    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',

When I add the echo $post->content . PHP_EOL; to the code, I noticed that before Ingest.php throws InvalidArgumentException, a very long post is printed in the console and it stayed there for quite a while. I guess it is something related to size limit exceeded...

@n0099
Copy link
Contributor

n0099 commented Oct 31, 2022

a very long post is printed in the console and it stayed there for quite a while

After update codes near

$ingest->push('postCollection', 'flarumBucket', $post->id,$post->content, $locale);
to:
image
we can see that for a 52kib long string it takes 60s long hanging to throw the exception:
image

So I guess there might be some hard timeout limit being set to 60s

I guess it is something related to size limit exceeded...

This issue from dependency might be related: ppshobi/psonic#23
After applying this pr manually, I'm still encountering this exception.

@n0099
Copy link
Contributor

n0099 commented Oct 31, 2022

A temp workaround is to continue push after the exception thrown after 60s timeout, for this u can update this line

$ingest->push('postCollection', 'flarumBucket', $post->id,$post->content, $locale);
with

                try {
                    $ingest->push('postCollection', 'flarumBucket', $post->id,$post->content, $locale);
                } catch (\Throwable $th) {
                    echo "$post->id failed: " . strlen($post->content) . ' bytes ' . round((microtime(true) - $start) * 1000, 2) . 'ms passed' . PHP_EOL;
                }

@n0099
Copy link
Contributor

n0099 commented Oct 31, 2022

I found a note from the author of upstream sonic repo: valeriansaliou/sonic#43 (comment)

Notice that there's no ERR for the async protocol (ie. if an EVENT never comes due to an error). You may thus implement a timeout strategy on your end.

@ganuonglachanh
Copy link
Owner

Thanks @n0099 for the investigation, fixed in new release

@tansongchen
Copy link

Hi @ganuonglachanh , I'm willing to tryout the new fix, but it seems that the new release is not installable by composer? Running composer update still gives 0.1.5

@n0099
Copy link
Contributor

n0099 commented Jan 14, 2023

Seems he forgot to sync the release on packagist.
You can manually change the composer package source to the github repo: https://stackoverflow.com/questions/12954051/use-php-composer-to-clone-git-repo https://getcomposer.org/doc/05-repositories.md, or just git clone and rename its path inside vendor.

@tansongchen
Copy link

Seems he forgot to sync the release on packagist.

You can manually change the composer package source to the github repo: https://stackoverflow.com/questions/12954051/use-php-composer-to-clone-git-repo https://getcomposer.org/doc/05-repositories.md, or just git clone and rename its path inside vendor.

Good suggestion, will try 😋

@ganuonglachanh
Copy link
Owner

Released new version, I lost in time @@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants