yougov / mongo-connector

MongoDB data stream pipeline tools by YouGov (adopted from MongoDB)
Apache License 2.0
1.88k stars 478 forks source link

Elasticsearch 'no such index' and 'failed to parse [timestamp]' errors #524

Open anekix opened 8 years ago

anekix commented 8 years ago

i am trying to insert data from mongodb to elasticsearch . using a 3 member replica set in mongo on my local system it is working perfectly fine but on my prod server i get the weird errors

OperationFailed: TransportError(400, u'mapper_parsing_exception', u'failed to parse [timestamp]')
2016-09-12 16:17:42,378 [ERROR] mongo_connector.oplog_manager:317 - Unable to process oplog document {u'h': -8493733748841374567L, u'ts': Timestamp(1473677229, 1), u'o': {u'create': u'uu'}, u't': 4L, u'v': 2, u'ns': u'rr.$cmd', u'op': u'c'}
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/mongo_connector/oplog_manager.py", line 312, in run
    timestamp)
  File "/usr/local/lib/python2.7/dist-packages/mongo_connector/util.py", line 43, in wrapped
    reraise(new_type, exc_value, exc_tb)
  File "/usr/local/lib/python2.7/dist-packages/mongo_connector/util.py", line 32, in wrapped
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/mongo_connector/doc_managers/elastic2_doc_manager.py", line 132, in handle_command
    "_source": {"enabled": True}
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/indices.py", line 291, in put_mapping
    '_mapping', doc_type), params=params, body=body)
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.py", line 329, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.py", line 109, in perform_request
    self._raise_error(response.status, raw_data)
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py", line 108, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
OperationFailed: TransportError(404, u'index_not_found_exception', u'no such index')

the error came when mapping of timestamp field was changed from yyyyMMdd to yyyy-MM-dd while . why it works on local but not on production server? i reindexed every document update mapping also

llvtt commented 8 years ago

It looks like mongo-connector is making a request to an index that doesn't exist yet. This has been a common pitfall, so I've added instructions on how to avoid this to the "Usage with Elastic" page: https://github.com/mongodb-labs/mongo-connector/wiki/Usage-with-ElasticSearch#operationfailed-transporterror404-uindex_not_found_exception. Let me know if you think these instructions can be improved in any way.

anekix commented 8 years ago

hi thanks for a quick reply . but on top of log file it also mentions

OperationFailed: TransportError(400, u'mapper_parsing_exception', u'failed to parse [timestamp]')
2016-09-12 16:17:42,378 [ERROR] mongo_connector.oplog_manager:317 - Unable to process oplog document {u'h': -8493733748841374567L, u'ts': Timestamp(1473677229, 1), u'o': {u'create': u'uu'}, u't': 4L, u'v': 2, u'ns': u'rr.$cmd', u'op': u'c'}
Traceback (most recent call last):

why is that?? also if it was because of index not being created then it would not run if i just change the mapping of date from yyyy-MM-dd to yyyyMMdd, it works perfecly if i just change the mapping .as far i found we can use use yyyy-MM-dd as date format in elastic search .

llvtt commented 8 years ago

Mongo connector does not change the format of date strings; they will be sent as-is to Elastic. If Elastic is unable to parse these date strings for some reason, then the problem likely has to do with some Elastic configuration.

anekix commented 8 years ago

i thought that too but verified its a correct format in elastic also the same format is working perfectly in my local environment mongo-connector does not gives any error.

anekix commented 8 years ago

also i am getting this error now

2016-09-14 11:21:24,983 [ERROR] mongo_connector.oplog_manager:205 - OplogThread: Last entry no longer in oplog cannot recover! Collection(Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True, replicaset=u'rs0'), u'local'), u'oplog.rs')
2016-09-14 11:21:25,940 [ERROR] mongo_connector.connector:304 - MongoConnector: OplogThread <OplogThread(Thread-2, stopped 140260588488448)> unexpectedly stopped! Shutting down
anekix commented 8 years ago

Issue have been fixed i just removed oplog.timestamp and restarted mongo-connector with --v flag it is working now.

ShaneHarvey commented 7 years ago

Glad to hear it's working now, did you find the root problem? Can you post it here in case others have the same issue?