I have a scheduler which polls data in every 4 hours and inserts into table based upon certain logic.
I have also used @Transactional annotation and also I am checking every time whether data already exists in the table or not.
If the record does not exist, it will insert. When I am multiple instances of SpringBoot application, each instance runs the scheduler and some data not all get duplicated.
It means I found that table contains duplicate record. The table where I am inserting is an existing table of the application and few columns have not been defined with unique
constraints. Please suggest me how I can maintain unique records in the database table even if scheduler runs from multiple instances. I am using Postgresql and SpringBoot.