toluaina / pgsync

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

Cannot run pysync after updating to the latest commit. #409

Closed nik13 closed 1 year ago

nik13 commented 1 year ago

PGSync version: 2.3.3

Postgres version: 13

Elasticsearch version: 8.4

Redis version: 7.0.5

Python version: 3.10

Problem Description: I was installing the pysync from master branch. Today when I updated my latest version, I cannot run the pgsync as its showing me following error to all my syncs.

Error Message (if any):

Traceback (most recent call last):
  File "/usr/local/bin/bootstrap", line 69, in <module>
    main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/bin/bootstrap", line 58, in main
    sync: Sync = Sync(
  File "/usr/local/lib/python3.10/site-packages/pgsync/singleton.py", line 17, in __call__
    cls._instances[key] = super(Singleton, cls).__call__(
  File "/usr/local/lib/python3.10/site-packages/pgsync/sync.py", line 101, in __init__
    self.validate(repl_slots=repl_slots)
  File "/usr/local/lib/python3.10/site-packages/pgsync/sync.py", line 180, in validate
    raise RuntimeError(
RuntimeError: Required materialized view columns not present on _view. Please re-run bootstrap.

It is showing me same error if I try to run bootstrap command. A validation was added in the latest commit. It seems that its not working as expected.

I also tried installing from commit ca76e53 and its working fine.

qbzenker commented 1 year ago

+1 I'm seeing the same issue

toluaina commented 1 year ago

This was due to a major change. Can you please run the two commands below first

bootstrap -c schema.json -t bootstrap -c schema.json

vivek-online commented 1 year ago
This was due to a major change.
Can you please run the two commands below first

bootstrap -c schema.json -t
bootstrap -c schema.json

I was also facing the same issue and tried your solution but it's not working for me.

indispeq commented 1 year ago

Hi, I am facing the exact same issue, I keep getting this error despite trying teardown and bootstrapping again.

toluaina commented 1 year ago

are you sure you:

mpaolino commented 1 year ago

@toluaina facing the same issue with:

I did this and the problem persists:

However, this version works just fine with PostgreSQL 14.5

vinhnxv commented 1 year ago

@toluaina facing the same issue with:

  • pgsync 2.5.0
  • OpenSearch 1.3

I did this and the problem persists:

  • ran bootstrap -c schema.json -t
  • followed by bootstrap -c schema.json

However, this version works just fine with PostgreSQL 14.5

I try to run: drop materialized view _view; to drop the materialized view (_view). And it worked fine.

SheLovesCode commented 1 year ago

are you sure you:

  • pulled the main branch from GitHub
  • ran bootstrap -c schema.json -t
  • followed bybootstrap -c schema.json
  • Can you share more details about the stack trace?
  • alternatively are you running under docker?

I'm also having the same error.

PGSync version: 2.5.0

Postgres version: 13

Elasticsearch version: 7.13.4

Redis version: 5.0

Python version: 3.7

I'm running under docker. The error occurred after I changed the name of a column in the database, I updated the schema.json to reflect the change but the error is still appearing.

toluaina commented 1 year ago

I am assuming the error you keep getting is "RuntimeError: Required materialized view columns not present on _view. Please re-run bootstrap."

Can you try this: psql> DROP MATERIALIZED VIEW _view; bootstrap -c schema.json -t bootstrap -c schema.json

Let me know if this resolves the issue. Seems the teardown is not removing all objects entirely.

SheLovesCode commented 1 year ago

@toluaina Dropping the materialized view resolved the issue. Thank you!

toluaina commented 1 year ago

Finally fixed in the main branch. Thanks and closing this issue