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

Remove CacheInvalidateRelcacheByTuple and put CronJobCacheValid in shmem #295

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fanfuxiaoran
Copy link

There is no need to call CacheInvalidateRelcacheByTuple when only updating the content of cron.job table( CacheInvalidateRelcacheByTuple should be called when the schema of crom.job udpated). Each time the CacheInvalidateRelcacheByTuple is called, the Relaion of pg_cron in launcher will be rebuilt which can lead some overhead.

Instead, put CronJobCacheValid into shmem, and set it to false in function InvalidateJobCache.

There is no need to call `CacheInvalidateRelcacheByTuple` when only
updating the content of cron.job table( `CacheInvalidateRelcacheByTuple`
should be called when the schema of crom.job udpated). Each time the
`CacheInvalidateRelcacheByTuple` is called, the `Relaion` of pg_cron in
launcher will be rebuilt which can lead some overhead.

Instead, put `CronJobCacheValid` into shmem, and set it to false in
function InvalidateJobCache.
@fanfuxiaoran
Copy link
Author

@microsoft-github-policy-service agree [company="{your company}"]

@fanfuxiaoran
Copy link
Author

@microsoft-github-policy-service agree

CachedCronJobRelationId = InvalidOid;
}
if (!pg_atomic_unlocked_test_flag_impl(CronJobCacheValid))
pg_atomic_clear_flag_impl(CronJobCacheValid);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I couldn't quite follow this approach. Shared memory does not follow transaction boundaries (we will see the valid flag become false before commit), whereas invalidations do.

Copy link
Author

Choose a reason for hiding this comment

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

I couldn't quite follow this approach. Shared memory does not follow transaction boundaries (we will see the valid flag become false before commit), whereas invalidations do.

Yes, I have dived into the invalidation method, when the transaction commited, the pg_cron laucher can receive the invalidation messages and call 'InvalidateJobCacheCallback' to set the 'CronJobCacheValid' to be false. And when the transaction is aborted, pg_cron launcher cannot receive any messages.
I agree that using the flag in shared memory can not follow transaction boundaries, although I can use a map to store the 'transactionID' and the ' CronJobCacheValid' value for each transaction and do something in at then end of the transaction, it looks a little complex.

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.

None yet

2 participants