Elasticsearch: Async handling of indexing/deletion requests#8465
Elasticsearch: Async handling of indexing/deletion requests#8465tobias-hotz wants to merge 39 commits intogeonetwork:mainfrom
Conversation
This improves indexing time, especially when the ES connection has a high latency or the ES load is high.
…in case on of not properly closed submittors
702dc20 to
83ea448
Compare
This causes issues with some tests. This issue was already present before the changes
ddb7766 to
948575b
Compare
767194b to
61fb7ad
Compare
|
Interesting work @tobias-hotz. We are also investigating how to improve indexing performances for GeoNetwork 5. See draft work geonetwork/geonetwork#19 and |
|
Hi @fxprunayre My first approach was to just return the Future of the index response to the caller, but that was getting pretty messy and it was easy to miss a call site. That's why I chose this approach. This change allows allows the multithreaded reindexing to work again (which is somewhat broken at the moment, mainly because of concurrency issues with the single document buffer for the bulk requests). This reduces the time spend on reindexing by a lot. So support for multithreaded indexing is something GN5 should also provide out of the box. |
…indexing # Conflicts: # services/src/main/java/org/fao/geonet/api/processing/DatabaseProcessUtils.java
…ectDeletionSubmitter.java Co-authored-by: Jose García <josegar74@gmail.com>
…ectIndexSubmitter.java Co-authored-by: Jose García <josegar74@gmail.com>
…letionSubmitter.java Co-authored-by: Jose García <josegar74@gmail.com>
…dexSubmitter.java Co-authored-by: Jose García <josegar74@gmail.com>
…ch/BatchingDeletionSubmitter.java Co-authored-by: Jose García <josegar74@gmail.com>
…ch/BatchingIndexSubmitter.java Co-authored-by: Jose García <josegar74@gmail.com>
…ch/BatchingSubmitterBase.java Co-authored-by: Jose García <josegar74@gmail.com>
…ch/StateBase.java Co-authored-by: Jose García <josegar74@gmail.com>
|
FYI, deployed on test env on some projects here. So far, all is working fine. |
# Conflicts: # core/src/main/java/org/fao/geonet/kernel/datamanager/IMetadataIndexer.java # core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataManager.java # core/src/main/java/org/fao/geonet/kernel/search/index/BatchOpsMetadataReindexer.java # core/src/test/java/org/fao/geonet/AbstractCoreIntegrationTest.java
ab3f611 to
e7e7466
Compare
e7e7466 to
861a285
Compare
|
I've rebased this PR onto the latest main branch once more. |
|
Thanks for the additional rebase @tobias-hotz. Indeed the changes looks to work well, no issue reported on indexing on my side. Discussing with @josegar74 yesterday, we propose to make 4.4.9 this month (or early October), and merge that PR just after so that everyone can test it for the 4.4.10 release. |
# Conflicts: # core/src/test/java/org/fao/geonet/AbstractCoreIntegrationTest.java # harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/geonet/BaseGeoNetworkAligner.java
# Conflicts: # harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/AbstractHarvester.java # plugins/datahub-integration/geonetwork-ui
|
Any news now that 4.4.10 is out? I've rebased this twice now since the release of that version |
|
Hi @josegar74 and @fxprunayre, |
|
Hi @tobias-hotz, as reported before, no issue reported on this so far on my side so it sounds good to go but it would be good to have others opinion ... |
|
@josegar74 Do you (or another reviewer) have any plans to tackle this? If yes, then I will continue rebasing this, but if the consensus is that this change is too risky or big to review or something else, then I don't need to keep updating the patch |
|
Sorry @tobias-hotz for being so slow reviewing PRs (definitely an area to improve). Discussing with @josegar74 this morning about this work, we propose to make 4.4.10 first (date is still uncertain but should happen in April). It will contain Elasticsearch version update (cf. #9176). Wait for the release to fix conflicts one more time so that we merge it early for 4.4.11. Is that fine for everyone? |
Currently, indexing is batched as a global queue of 200 elements (except when forceRefreshReaders is true). When the threshold is reached, the entries are submitted, and the thread submitting the 200th element waits until the elasticsearch returns the result of the request.
With deletion, we currently always send one request per deletion request and always use the deleteByQuery method.
The current design has a number of flaws:
This PR solves all of these problems. The main takeaway is that it significantly improves the performance of deleting and indexing many entries.
This is accomplished by introducing a
IIndexSubmitterandIDeletionSubmitter. These new classes handle how new entries are sent to the index. The direct implementations (DirectIndexSubmitterandDirectDeletionSubmitter) are similar to how the oldforceIndexChangesparameter worked in that they directly send the data to the index.With the use of the
BatchingIndexSubmitterandBatchingDeletionSubmittor, chunks are sent periodically to the elasticsearch (just as before), but a local queue is used, and we do not wait for the elasticearch. The index responses are handled asynchronously on a different thread instead. We still guarantee that the indexing will be complete once the whole block is done, as the close method sends the rest of the local queue and waits for all async responses to be complete.We made some performance measurements on a smaller scale. Here is the average result of a bunch of runs with different CSW harvesters:
As you can see, there are very significant performance gains. These numbers were recorded on a local machine, if you use a remote index on a different machine, the effect may be even higher due to latency/throughput limitations.
Checklist
mainbranch, backports managed with labelREADME.mdfilespom.xmldependency management. Update build documentation with intended library use and library tutorials or documentationFunded by LGL BW