nfsantos commented on code in PR #2121:
URL: https://github.com/apache/jackrabbit-oak/pull/2121#discussion_r1971706170


##########
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:
   And allocating 16MB of memory just to create a log message also sounds 
risky, as it can create memory pressure. For instance, if there are many 
writers, all hitting the same error, they would all in a short period of time 
allocate up to 32MB of memory (16MB for the full Json representation, then 16MB 
for the array split).



-- 
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: oak-dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to