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

log more info when fvh failed #618

Merged
merged 5 commits into from
Jan 22, 2024

Conversation

waziqi89
Copy link
Contributor

@waziqi89 waziqi89 commented Jan 22, 2024

The fvh exception is not logged properly. Fix the bug, and add more context on the message.
from

[WARN ] 2024-01-19 15:06:37.546 [GrpcLuceneServerExecutor-6-thread-28] NRTFastVectorHighlighter - FVH failed creating fragments, and the exception is: }

to

[WARN ] 2024-01-22 16:29:36.059 [GrpcLuceneServerExecutor-5-thread-17] NRTFastVectorHighlighter - FVH failed creating fragments for the luceneDocId: 1, highlight query: #_nested_path:reviews +(((reviews.raw_text:pepper)^5.0 (reviews.raw_text:salt)^3.0)~1), exception: dummy runtime exception
java.lang.RuntimeException: dummy runtime exception
        at com.yelp.nrtsearch.server.luceneserver.highlights.NRTFastVectorHighlighter.getHighlights(NRTFastVectorHighlighter.java:131) ~[nrtsearch-0.30.0.jar:?]
        at com.yelp.nrtsearch.server.luceneserver.highlights.HighlightFetchTask.processHit(HighlightFetchTask.java:80) ~[nrtsearch-0.30.0.jar:?]
        at com.yelp.nrtsearch.server.luceneserver.search.FetchTasks.processHit(FetchTasks.java:161) ~[nrtsearch-0.30.0.jar:?]
        at com.yelp.nrtsearch.server.luceneserver.SearchHandler$FillDocsTask.fetchSlice(SearchHandler.java:922) ~[nrtsearch-0.30.0.jar:?]
        at com.yelp.nrtsearch.server.luceneserver.SearchHandler$FillDocsTask.run(SearchHandler.java:850) ~[nrtsearch-0.30.0.jar:?]
        at com.yelp.nrtsearch.server.luceneserver.SearchHandler.fetchFields(SearchHandler.java:423) ~[nrtsearch-0.30.0.jar:?]
        at com.yelp.nrtsearch.server.luceneserver.SearchHandler.handle(SearchHandler.java:222) ~[nrtsearch-0.30.0.jar:?]
        at com.yelp.nrtsearch.server.grpc.LuceneServer$LuceneServerImpl.search(LuceneServer.java:1069) ~[nrtsearch-0.30.0.jar:?]
        at com.yelp.nrtsearch.server.grpc.LuceneServerGrpc$MethodHandlers.invoke(LuceneServerGrpc.java:3376) ~[clientlib-0.30.0.jar:?]
        at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182) ~[grpc-stub-1.46.0.jar:1.46.0]
        at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) ~[grpc-api-1.46.0.jar:1.46.0]
        at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) ~[grpc-api-1.46.0.jar:1.46.0]
        at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:340) ~[grpc-core-1.46.0.jar:1.46.0]
        at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:866) ~[grpc-core-1.46.0.jar:1.46.0]
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.46.0.jar:1.46.0]
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) ~[grpc-core-1.46.0.jar:1.46.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]



Note that the query would be the "LUCENE" query, but still informative for engineers to debug.

@@ -142,7 +142,11 @@ public String[] getHighlights(
DEFAULT_ENCODER);
} catch (RuntimeException runtimeException) {
logger.warn(
"FVH failed creating fragments, and the exception is: ", runtimeException.getMessage());
String.format(
Copy link
Contributor

@sarthakn7 sarthakn7 Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for String.format since you're only using logger, and you can also log the complete exception. So something like:

logger.warn(
              "FVH failed creating fragments for the luceneDocId: {}, highlight query: {}, exception: {}",
              leafDocId + hitLeaf.docBase,
              settings.getHighlightQuery(),
              runtimeException.getMessage(),
              runtimeException);

leafDocId + hitLeaf.docBase,
settings.getHighlightQuery(),
runtimeException.getMessage()));
runtimeException.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add the exception as well like I had added in my previous comment?
Also can you please test it locally and verify that the log works as expected now? You can add the logged message in the PR description.

Copy link
Contributor Author

@waziqi89 waziqi89 Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to reproduce the error unless we have a buggy analyzer. I created a dummy exception which will serve the test purpose.

"FVH failed creating fragments for the luceneDocId: {}, highlight query: {}, exception: {}",
leafDocId + hitLeaf.docBase,
settings.getHighlightQuery(),
runtimeException);
Copy link
Contributor

@sarthakn7 sarthakn7 Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waziqi89 if you log like this:

logger.warn(
              "FVH failed creating fragments for the luceneDocId: {}, highlight query: {}, exception: {}",
              leafDocId + hitLeaf.docBase,
              settings.getHighlightQuery(),
              runtimeException.getMessage(),
              runtimeException);

i.e. have the exception at the end without having a placeholder for it in the string message, it will log the entire stacktrace in addition to the message. Can you please do that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you don't want to log the stacktrace.

Copy link
Contributor Author

@waziqi89 waziqi89 Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the latest commit, the exception is logged instead of message. Guess the test result is misleading because the dummy exception has not stacktrace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have exception: {} it'll just log the exception message and not the stacktrace. Example:

try {
      throw new RuntimeException("Test");
    } catch (Exception e) {
      logger.warn("Error: {}, Exception: {}", "Test error", e);
    }

The output is:

[WARN ] 2024-01-22 11:15:33.268 [Test worker] LoggerTest - Error: Test error, Exception: java.lang.RuntimeException: Test

vs

try {
      throw new RuntimeException("Test");
    } catch (Exception e) {
      logger.warn("Error: {}, Exception: {}", "Test error", e.getMessage(), e);
    }

Output:

[WARN ] 2024-01-22 11:17:36.810 [Test worker] LoggerTest - Error: Test error, Exception: Test
java.lang.RuntimeException: Test
	at com.yelp.nrtsearch.LoggerTest.logExceptionTest(LoggerTest.java:20) ~[test/:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) ~[junit-4.13.2.jar:4.13.2]
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413) ~[junit-4.13.2.jar:4.13.2]
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) ~[?:?]
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) ~[?:?]
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) ~[?:?]
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) ~[?:?]
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) ~[?:?]
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) ~[?:?]
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) ~[?:?]
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) ~[?:?]
	at jdk.proxy2.$Proxy5.processTestClass(Unknown Source) ~[?:?]
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) ~[?:?]
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) ~[?:?]
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) ~[?:?]
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) ~[?:?]
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) ~[?:?]
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) ~[?:?]
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) ~[?:?]
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) ~[gradle-worker.jar:?]
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) ~[gradle-worker.jar:?]

As you can see there is no stacktrace in the first case.

Copy link
Contributor

@sarthakn7 sarthakn7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please also update the description with the new log that includes the stacktrace?

@waziqi89 waziqi89 merged commit 8478ec7 into Yelp:master Jan 22, 2024
1 check passed
@waziqi89 waziqi89 deleted the u/waziqi/fvh-elaborative-exception branch January 22, 2024 21:30
sarthakn7 added a commit that referenced this pull request Mar 1, 2024
* Fix node resolver for empty/missing files (#587)

* Autogenerated JaCoCo coverage badge

* Bump to v0.26.1 (#588)

* Autogenerated JaCoCo coverage badge

* parallel explain for nrtsearch (#589)

* parallel explain for nrtsearch

* fix nit

* add explain for multi segment parallel

* refactor isExplain in different contexts

* make NRTSearch empty boolean query result constant score 1 (#592)

* make NRTSearch empty boolean query result constant score 1

* fix tests

* soft exception for fvh failures (#593)

* Support unit in SortType (#590)

create sort context and support unit in lat_lon distance sort

* Autogenerated JaCoCo coverage badge

* Upgrade dependencies for snyk check (#596)

* Fix example-plugin test (#598)

* Add page fault metrics (#599)

* Add additional merge metrics (#607)

* Add live setting for verbose index metrics (#608)

* Add live setting for verbose index metrics

* Address review comment

* Autogenerated JaCoCo coverage badge

* Bump to v0.29.0 (#609)

* Add live index settings override from config file (#610)

* Autogenerated JaCoCo coverage badge

* Add ability to update local index live settings (#611)

* Add deadline cancellation for indexing (#612)

* Add geo polygon query type (#613)

* Add geo polygon query type

* Detect closed polygons, update docs

* Autogenerated JaCoCo coverage badge

* Bump to v0.30.0 (#615)

* Testing readthedocs web hooks (#616)

* Add a bare minimum readthedocs config file (#617)

* log more info when fvh failed (#618)

 log more info when fvh failed

* Avoid calling query.toString() (#619)

* add sts for web identity auth (#620)

add sts for web identity auth

* Add search diagnostics to deadline exceeded exceptions (#621)

* Add search diagnostics to deadline exceeded exceptions
---------

Co-authored-by: swekannan <shwethu.kannan93@gmail.com>

* Fixes and spotless apply

* Updated grpc-gateway

---------

Co-authored-by: Andrew Prudhomme <asp@yelp.com>
Co-authored-by: github_actions <runner@fv-az248-700.3twvhzoricxu3figbgb44chhog.cx.internal.cloudapp.net>
Co-authored-by: github_actions <runner@fv-az887-622.kyhrjabtieueri5x0cgfkhfc1a.bx.internal.cloudapp.net>
Co-authored-by: Tao Yu <taoyu@yelp.com>
Co-authored-by: waziqi89 <89210409+waziqi89@users.noreply.github.com>
Co-authored-by: github_actions <runner@fv-az248-372.3twvhzoricxu3figbgb44chhog.cx.internal.cloudapp.net>
Co-authored-by: github_actions <runner@fv-az574-753.esnmgxn14wlejbqjnvhsbsbtxa.dx.internal.cloudapp.net>
Co-authored-by: github_actions <runner@fv-az1272-720.grsihaubamwerhiryzjrxtypna.phxx.internal.cloudapp.net>
Co-authored-by: github_actions <runner@fv-az736-601.alpbqrzxv30uzkvtn2qktnuusd.cx.internal.cloudapp.net>
Co-authored-by: Mohammad Mohtasham <mohm@yelp.com>
Co-authored-by: swekannan <62616258+swekannan@users.noreply.github.com>
Co-authored-by: swekannan <shwethu.kannan93@gmail.com>
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

Successfully merging this pull request may close these issues.

2 participants