【问题标题】:FusionAuth incomplete reindex with AWS ElasticsearchFusionAuth 使用 AWS Elasticsearch 重新索引不完整
【发布时间】:2020-06-02 08:29:44
【问题描述】:

我正在从自托管的 Elasticsearch FusionAuth 搜索迁移到 AWS Elasticsearch Service 解决方案。

我有一个新的 FusionAuth 应用程序 EC2 实例,它从配置为使用新的 Elasticsearch 服务的使用中的数据库中读取数据。

在从新应用实例触发重新索引时,我发现只有大约 60k 或 62.5k 文档被写入新索引,而我预计大约 600 万。

我没有看到来自 AWS 的 Elasticsearch 服务的错​​误,并且在应用程序的日志中我可以看到:(故意省略端点)

Feb 13, 2020 10:18:46.116 AM INFO  io.fusionauth.api.service.search.ElasticSearchClientProvider - Connecting to FusionAuth Search Engine at [https://vpc-<<omitted>>.eu-west-1.es.amazonaws.com]
13-Feb-2020 11:19:55.176 INFO [http-nio-9011-exec-3] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
        java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
                at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:430)
                at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:684)
                at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
                at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
                at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
"/usr/local/fusionauth/logs/fusionauth-app.log" [readonly] 43708L, 4308629C                                                                                                                                                                                                                                                                               42183,1       96%
        at io.fusionauth.api.service.search.client.domain.documents.IndexUser.<init>(IndexUser.java:79)
        at io.fusionauth.api.service.search.ElasticsearchSearchEngine.lambda$index$1(ElasticsearchSearchEngine.java:140)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at io.fusionauth.api.service.search.ElasticsearchSearchEngine.index(ElasticsearchSearchEngine.java:140)
        at io.fusionauth.api.service.user.ReindexRunner$ReindexWorker.run(ReindexRunner.java:101)
        at java.lang.Thread.run(Thread.java:748)
Exception in thread "Thread-14" java.lang.NullPointerException
        at io.fusionauth.api.service.search.client.domain.documents.IndexUser.<init>(IndexUser.java:79)
        at io.fusionauth.api.service.search.ElasticsearchSearchEngine.lambda$index$1(ElasticsearchSearchEngine.java:140)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at io.fusionauth.api.service.search.ElasticsearchSearchEngine.index(ElasticsearchSearchEngine.java:140)
        at io.fusionauth.api.service.user.ReindexRunner$ReindexWorker.run(ReindexRunner.java:101)
        at java.lang.Thread.run(Thread.java:748)
Exception in thread "Thread-13" java.lang.NullPointerException
Exception in thread "Thread-11" java.lang.NullPointerException
Exception in thread "Thread-12" java.lang.NullPointerException
Feb 18, 2020 10:23:29.064 AM INFO  io.fusionauth.api.service.user.ReindexRunner - Reindex completed in [86797] ms or [86] seconds.

虽然有一些例外,但最后还有一个“重新索引已完成”INFO 日志。

不了解 Elasticsearch 的来龙去脉,我也不知道从哪里开始调查 NullPointerException。

【问题讨论】:

    标签: java amazon-web-services elasticsearch fusionauth


    【解决方案1】:

    看起来重新索引操作出现异常,这可能是导致索引被截断的原因。

    Exception in thread "Thread-14" java.lang.NullPointerException
            at io.fusionauth.api.service.search.client.domain.documents.IndexUser.<init>(IndexUser.java:79)
    
    

    此代码假设您有用户名或电子邮件地址。这应该由 FusionAuth API 强制执行。但在这种情况下,要发生此异常,电子邮件和用户名都是 NULL

    您是如何使用 Import API、User API 或其他方式让用户进入数据库的?

    理论上,您应该至少找到一个电子邮件和用户名具有NULL 值的用户。

    这个查询 - 或类似的 - 应该找到有问题的用户,然后我们需要确定这个用户是如何添加到 FusionAuth 中的。

    SELECT email, username from identities WHERE email IS NULL OR username IS NULL
    

    【讨论】:

    • 我们使用导入 API 将大部分用户导入数据库。而且由于我们已经将所有用户索引到另一个索引中,我不会期望数据库有错误的数据。无论如何,我检查了它,没有任何用户没有电子邮件或用户名,或者没有电子邮件的任何实例。
    • 有没有办法改变索引批量大小?在我看来,它目前每次同步 2.5k 批,并且在 25 次运行后失败。我想尝试修改它以尝试找到某种模式。我们的数据都不是NULL
    • 我注意到日志提到:/mappings/user.json - 有什么地方可以找到吗?我们的用户名为空,但任何人的电子邮件都不为空
    • @KasiaGogolek 可以修改默认值,将这两个值添加到fusionauth.propertiesfusionauth-app.reindex-batch-sizefusionauth-app.reindex-thread-count。 (需要重新启动)我们最近将默认批量减少到 2 个线程的 1k 批量大小。如果您使用的是旧版本,则它是 5 个线程 w/2.5k 批量大小。这对于较小的系统来说有点激进。
    • @KasiaGogolek re: user.json 这是我们为用户提供的基本映射,您可以随时通过 Elastic API 查询 Elastic 的当前映射值。
    猜你喜欢
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    • 2017-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多