Skip to content

Conversation

@epoberezkin
Copy link
Member

No description provided.

total_deleted BIGINT := 0;
BEGIN
FOR rid IN
SELECT recipient_id
Copy link
Member Author

Choose a reason for hiding this comment

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

implicit cursor here is:

  • bad for large tables
  • disrupted with commits.

Instead batching is used

del_count := delete_expired_msgs(rid, old_ts);
total_deleted := total_deleted + del_count;
EXCEPTION WHEN OTHERS THEN
ROLLBACK;
Copy link
Member Author

Choose a reason for hiding this comment

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

rollback is automatic here, but commit that would release lock is not, so explicit commit is still neded

@epoberezkin epoberezkin merged commit a137d01 into db-messages Sep 12, 2025
3 of 6 checks passed
@epoberezkin epoberezkin deleted the ep/fix-counts branch September 12, 2025 10:39
epoberezkin added a commit that referenced this pull request Sep 16, 2025
…sage store (#1631)

* smp server: improve counts management and expiration for postgres message store

* one update

* fix expiration
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.

2 participants