thomasmueller commented on code in PR #2121:
URL: https://github.com/apache/jackrabbit-oak/pull/2121#discussion_r1973844846
##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java:
##########
@@ -204,11 +204,35 @@ private void provisionIndex() throws IOException {
if (ese.status() == 400 &&
ese.getMessage().contains("resource_already_exists_exception")) {
LOG.warn("Index {} already exists. Ignoring error", indexName);
} else {
+ LOG.warn("Failed to create index {}", indexName, ese);
+ StringBuilder sb = new StringBuilder();
+ int old = JsonpUtils.maxToStringLength();
+ try {
+ JsonpUtils.maxToStringLength(16_000_000);
+ JsonpUtils.toString(request, sb);
+ String[] array = splitLargeString(sb.toString(), 1024);
+ for (int i = 0; i < array.length; i++) {
+ LOG.warn("request chunk[{}] = {}", i, array[i]);
+ }
+ } finally {
+ JsonpUtils.maxToStringLength(old);
+ }
Review Comment:
Notice this is just the _maximum_ length. The default maximum length is
10'000 characters, and unfortunately, the interesting part is not logged at all
at that length. The request for a "normal" index definition is around 13'000
characters. So we could limit to 100'000. However, possibly this is not enough:
it is hard to tell. But I changed it to 1 MB now.
> allocating 16MB of memory
It doesn't allocate 16 MB of memory. Internally, JsonpUtils uses
StringBuilder, which doesn't allocate 16 MB either, if the message is smaller.
> which could lead to us losing other logs which are more important
This message is important, because without it, it is very hard to understand
why building the index failed. Truncating this message would be very
problematic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]