I have a postgresql 14 database on a vps (Ubuntu 22) and I constantly run into the problem that it sometimes just stops working
then I have to run the following command sudo systemctl restart postgresql.service
and then my db starts working again
now recently it happened again
but after running sudo systemctl restart postgresql.service
all my tables just dissappeared
anyone an idea what could cause smth like this?
Image
Image
This is the journalctl
Image
It crashed while doing queries shown in the following code
pol_scraper = PolygonScraper()
conn = pg.connect(
"dbname=postgres user=postgres password=mypw host=myhost port=5432"
)
cur = conn.cursor()
max_block = pol_scraper.web3.eth.block_number
# max_block = 57063842
for i, ((block, transaction_hash), transfer) in tqdm(enumerate(pol_scraper.get_all_data(0, max_block))):
# print(block)
# print(transfer['value'])
try:
cur.execute(
"""
INSERT INTO polymarket_transfers (type, token_address, sender, receiver, token_id, transfer_event, value, transaction_hash, block_number)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) ON CONFLICT DO NOTHING""",
(
transfer['type'],
transfer['token_address'],
transfer['from'],
transfer['to'],
transfer['token_id'],
transfer['transfer_event'],
transfer['value'],
transaction_hash,
block
),
)
conn.commit()
if i % 5000 == 0:
print(f"Last trade: {transaction_hash}, {block}")
except Exception as e:
print(e)
print(transaction_hash)
print(transfer)![Image](https://media.discordapp.net/attachments/291284109232308226/1243479298929852498/image.png?ex=66524897&is=6650f717&hm=341b11c7efc02145fe9ae436d3370a2fca315743e430eb90fffac3f3d3c583e7&=&format=webp&quality=lossless&width=800&height=222)