How to suppress DocumentMissingException?

Hi,

I have the following workflow in an application

  1. update the doc with fresh data, if it succeeds, work is done
  2. if the doc was missing, do some local work and when that succeeds, index the data

In step 2 it's important that the doc must only appear in ES when the local work is successfully done.

This works nicely, my only problem is every update on a -yet- nonexistent doc yields about 1.7 kiBs of stack trace into the ES log (and to that matter, onto its stdout by default), which is absolutely wasted, both CPU and IO/storage wise.

This is it:
[2016-02-27 15:31:54,266][INFO ][rest.suppressed ] /idx1/object/954003.84.t/_update Params: {index=idx1, id=954003.84.t, type=object, retry_on_conflict=8}
RemoteTransportException[[dev00][192.168.0.170:9301][indices:data/write/update[s]]]; nested: DocumentMissingException[[object][954003.84.t]: document missing];
Caused by: [idx1][[idx1][2]] DocumentMissingException[[object][954003.84.t]: document missing]
at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:90)
at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:79)
at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:170)
at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:164)
at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:65)
at org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$ShardTransportHandler.messageReceived(TransportInstanceSingleOperationAction.java:249)
at org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$ShardTransportHandler.messageReceived(TransportInstanceSingleOperationAction.java:245)
at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:350)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

How do I silence this?

1 Like

Use upsert:

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#upserts

Or you can try to change the log level:

https://www.elastic.co/guide/en/elasticsearch/guide/current/logging.html

Upsert is not good for me, because of #2 (I have work to do before indexing data).
I want to disable only this exception, because it's excess and hurts performance badly. If I change the loglevel, it affects many other events.

So first, check that the doc exists or not in ES, then update or insert.

Note: you can use https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html to bulk operations.

That's what I do now, but I feel it totally unecessary, when a simple update should do the job, without the overhead of that extra get.