toluaina / pgsync

Postgres to Elasticsearch/OpenSearch sync
https://pgsync.com
MIT License
1.11k stars 174 forks source link

list index out of range - error #411

Closed sundarvc closed 1 year ago

sundarvc commented 1 year ago

PGSync version: 2.4.0

Postgres version: 15.1

Elasticsearch version: 8.5.3

Redis version: 7.0.7

Python version: 3.10.6

Problem Description:

Getting list index out of range while , trying to update index with new data.

Error Message (if any):

2023-01-09 00:23:33.882:ERROR:pgsync.elastichelper: Exception list index out of range Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/elastichelper.py", line 129, in bulk self._bulk( File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/elastichelper.py", line 186, in bulk for in helpers.parallel_bulk( File "/home/ubuntu/.local/lib/python3.10/site-packages/elasticsearch/helpers/actions.py", line 472, in parallel_bulk for result in pool.imap( File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next raise value File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, kwds)) File "/usr/lib/python3.10/multiprocessing/pool.py", line 144, in _helper_reraises_exception raise ex File "/usr/lib/python3.10/multiprocessing/pool.py", line 391, in _guarded_task_generation for i, x in enumerate(iterable): File "/home/ubuntu/.local/lib/python3.10/site-packages/elasticsearch/helpers/actions.py", line 155, in _chunk_actions for action, data in actions: File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/sync.py", line 807, in _payloads filters = self._insert_op( File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/sync.py", line 486, in _insert_op if key == foreign_keys[node.parent.name][i]: IndexError: list index out of range 0:00:00.355160 (0.36 sec) Traceback (most recent call last): File "/home/ubuntu/.local/bin/pgsync", line 7, in sync.main() File "/home/ubuntu/.local/lib/python3.10/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/home/ubuntu/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/ubuntu/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/ubuntu/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(args, kwargs) File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/sync.py", line 1386, in main sync.pull() File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/sync.py", line 1162, in pull self.logical_slot_changes(txmin=txmin, txmax=txmax, upto_nchanges=None) File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/sync.py", line 436, in logical_slot_changes self.es.bulk(self.index, self._payloads(payloads)) File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/elastichelper.py", line 129, in bulk self._bulk( File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/elastichelper.py", line 186, in bulk for in helpers.parallel_bulk( File "/home/ubuntu/.local/lib/python3.10/site-packages/elasticsearch/helpers/actions.py", line 472, in parallel_bulk for result in pool.imap( File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next raise value File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, **kwds)) File "/usr/lib/python3.10/multiprocessing/pool.py", line 144, in _helper_reraises_exception raise ex File "/usr/lib/python3.10/multiprocessing/pool.py", line 391, in _guarded_task_generation for i, x in enumerate(iterable): File "/home/ubuntu/.local/lib/python3.10/site-packages/elasticsearch/helpers/actions.py", line 155, in _chunk_actions for action, data in actions: File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/sync.py", line 807, in _payloads filters = self._insert_op( File "/home/ubuntu/.local/lib/python3.10/site-packages/pgsync/sync.py", line 486, in _insert_op if key == foreign_keys[node.parent.name][i]: IndexError: list index out of range```

sundarvc commented 1 year ago

I had a many-to-many relationship in my schema. After removing it, it works fine now...