nxus / searcher

MIT License
0 stars 0 forks source link

Version conflict errors on updates. #12

Open davidkellerman opened 6 years ago

davidkellerman commented 6 years ago

When updating records, Elasticsearch generates "version conflict" errors. It seems to do the update, but the error messages really overwhelm the logging.

Unhandled rejection Error (E_UNKNOWN) :: Encountered an unexpected error
[version_conflict_engine_exception] [searchdocument][5b768d3a11dcb10033025d05]: version conflict, current version [3] is different than the one provided [2], with { index_uuid="gjJY6CPfRbiUMc2wSaLfdw" & shard="0" & index="gf-assess" } :: {"path":"/gf-assess/searchdocument/5b768d3a11dcb10033025d05/_update","query":{},"body":"{\"doc\":{\"model\":\"gfpp_supplier\",\"uniqueId\":\"001283-A\",\"supplierId\":1283,\"locationId\":\"A\",\"name\":\"J Brand Cattle Co\",\"type\":\"Producer\",\"address\":{\"type\":\"Feature\",\"uid\":\"postalcode\",\"properties\":{\"raw\":\"Healdsburg, CA, US\",\"city\":\"Healdsburg\",\"state\":\"California\",\"country\":\"United States of America\"}},\"productionLocation\":{\"type\":\"Feature\",\"uid\":\"osm:33159329\",\"properties\":{\"point\":{\"lat\":38.610516,\"lng\":-122.8813407},\"extent\":[-122.881623,38.60941,-122.880855,38.610968],\"country\":\"United States of America\",\"city\":\"Healdsburg\",\"state\":\"California\",\"osm_id\":33159329,\"osm_type\":\"W\",\"osm_value\":\"city\"}},\"herdSize\":null,\"acreage\":null,\"revenue\":null,\"localNote\":null,\"sustainableNote\":null,\"valuedCertifications\":null,\"valuedNote\":null,\"humaneCertifications\":[\"animal-welfare-approved\"],\"humaneNote\":\"ASPCA Good Food Meat Producers CA\",\"foodSafetyNote\":null,\"ownershipStructure\":[\"family-owned\",\"privately-owned\"],\"externalProductTypes\":null,\"contactPerson\":\"Steve Jacobs\",\"contactEmail\":\"steve@jbrandllc.com\",\"headquartersLocation\":null,\"externalPurchasers\":null,\"createdAt\":\"2018-08-17T08:54:18.993Z\",\"updatedAt\":\"2018-08-20T19:59:46.339Z\",\"primaryLocation\":\"5b768d3a11dcb10033025d05\",\"sustainableCertifications\":[\"animal-welfare-approved\",\"pasture-raised\"],\"contactPhone\":null,\"productCategory\":\"meats,poultry\",\"id\":\"5b768d3a11dcb10033025d05\"},\"doc_as_upsert\":true}","statusCode":409,"response":"{\"error\":{\"root_cause\":[{\"type\":\"version_conflict_engine_exception\",\"reason\":\"[searchdocument][5b768d3a11dcb10033025d05]: version conflict, current version [3] is different than the one provided [2]\",\"index_uuid\":\"gjJY6CPfRbiUMc2wSaLfdw\",\"shard\":\"0\",\"index\":\"gf-assess\"}],\"type\":\"version_conflict_engine_exception\",\"reason\":\"[searchdocument][5b768d3a11dcb10033025d05]: version conflict, current version [3] is different than the one provided [2]\",\"index_uuid\":\"gjJY6CPfRbiUMc2wSaLfdw\",\"shard\":\"0\",\"index\":\"gf-assess\"},\"status\":409}"}
    at respond (/Users/david_kellerman/Documents/Seabourne/gf-assess/node_modules/elasticsearch/src/lib/transport.js:307:15)
    at checkRespForFailure (/Users/david_kellerman/Documents/Seabourne/gf-assess/node_modules/elasticsearch/src/lib/transport.js:266:7)
    at HttpConnector.<anonymous> (/Users/david_kellerman/Documents/Seabourne/gf-assess/node_modules/elasticsearch/src/lib/connectors/http.js:159:7)
    at IncomingMessage.bound (/Users/david_kellerman/Documents/Seabourne/gf-assess/node_modules/elasticsearch/node_modules/lodash/dist/lodash.js:729:21)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1056:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
loppear commented 6 years ago

Yeah, need to figure out what's generating these - I'm wondering if there's a duplicate update being sent, since docs and error would indicate this by itself won't do the update, but it does seem to be updated in ES.

loppear commented 6 years ago

More generally, we should be catching exceptions on update and really logging them at a minimum, rather than this unhandled noise.

loppear commented 6 years ago

Any steps to reproduce you can add, I've seen these but not currently able to cause it. Not sure what document index call would cause the _version to actually be included in the doc sent to ES so maybe this is internally triggered by ... I don't know. ES docs suggest that version checking is only done if the version is sent in the update, and it's true I don't see version in what I'm sending that isn't causing this today...