toluaina / pgsync

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

Plugin is not executed for new records after initial sync #375

Closed goktugbati closed 1 year ago

goktugbati commented 1 year ago

PGSync version: latest

Postgres version:

Elasticsearch version: 7.14.2

Redis version: latest

Python version: 3.7

Problem Description: When I run pgsync using docker compose locally it syncs when a new data is added or removed from the database but when I run it on openshift in our dev environment, only the remove operations sync successfully. I found that new records are pushed to elastic search but without running the plugin Plugin: `from pgsync import plugin

def transform(self, doc, **kwargs):
    if doc['state'] == 0:
        doc['enabled'] = True
    else:
        doc['enabled'] = False
    tags = []
    for i in range(0,len(doc['tagNames'])):
        tags.append({"id":doc['tagIds'][i], "name":doc['tagNames'][i]})
    breadcrumbs = []
    for i in range(0,len(doc['categoryNames'])):
        breadcrumbs.append({"name":doc['categoryNames'][i],"alias":doc['categoryAliases'][i]})
    doc['tags'] = tags
    doc['breadcrumbs'] = breadcrumbs
    del doc['tagNames']
    del doc['categoryIds']
    del doc['categoryNames']
    del doc['categoryAliases']
    return doc

` Sync tic_devdb Xlog: [0] => Db: [31] => Redis: [total = 31 pending = 0] => Elastic: [2,647] ...

Could it be about the checkpoint file ? Because it syncs when I restart the pod

toluaina commented 1 year ago
goktugbati commented 1 year ago

Hi, I'm running openshift on dev environment but I noticed that the error is not about execution of the plugin. I added logs to plugin and apparently it modifies the data as expected but the data pushed to elastic doesn't have most of the fields that it should have and the ones that it has are empty except for 2 fields. So most probably something happens right before pushing the data. Do you think I should create a new issue or edit this one ? In my local environment it always syncs successfully when a new record is added. I'll check elastic logs as well.