Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

premature invoice deletion: fix interval in sql template #1498

Merged
merged 2 commits into from
Oct 19, 2024
Merged

Conversation

huumn
Copy link
Member

@huumn huumn commented Oct 19, 2024

fixes #1485

It looks like prisma's interpretation of intervals in templates changed at some point. I didn't find anywhere else where we use intervals this way.

QA: 6. made invoices, reproduced bug, then made some more invoices, ran job - no deletions, made one of the invoices artificially old, ran job - only old one deleted.

@huumn huumn changed the title fix interval in sql template premature invoice deletion: fix interval in sql template Oct 19, 2024
Copy link
Member

@ekzyis ekzyis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also reproduced the bug. Makes sense that this syntax confuses Prisma. I also tested it with this query:

await models.$queryRaw`
SELECT id, created_at
FROM "Withdrawl"
WHERE now() > created_at + interval '${'1 year'}'`

It fetched withdrawals that were clearly too young. Using Prisma.sql didn't explain how Prisma interprets this though:

console.log(Prisma.sql`
SELECT id, created_at
FROM "Withdrawl"
WHERE now() > created_at + interval '${'1 year'}'
AND hash = '${'how does this look in Prisma.sql?'}'`.sql)
SELECT id, created_at
FROM "Withdrawl"
WHERE now() > created_at + interval '?'
AND hash = '?'

On a sidenote, I think we should also delete preimages since we delete payment hashes but they can be derived from the preimage or only delete bolt11s.

I think the question why we not only delete bolt11s came up before. The reason was that payment hashes are sensitive because they can be used for correlation iirc.

Following that reasoning, we should then also delete preimages.

@huumn
Copy link
Member Author

huumn commented Oct 19, 2024

true we weren't storing the preimages in all cases before

@huumn huumn merged commit 7aa0d8f into master Oct 19, 2024
6 checks passed
@huumn huumn deleted the fix-1485 branch October 19, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

premature invoice deletion
2 participants