Conversation
6bddcf6 to
2d6790a
Compare
da47acd to
1f988ae
Compare
|
requires #4936 to be merged first |
1f988ae to
1d032b9
Compare
| if key_type == "test": | ||
| return None | ||
|
|
||
| if require_status_from_primary_row and not notification_status: |
There was a problem hiding this comment.
Do we actually need this condition check? Updated notifications always have a previous notification_status from the database, this condition seems redundant and a bit confusing.
There was a problem hiding this comment.
This is needed, however, it wasn't working as expected. I have fixed it and added some comments to support it
09efa7c to
29d32f3
Compare
|
|
||
|
|
||
| @notify_celery.task(name="process-notifications-replication-slot-changes") | ||
| def process_replication_slot_changes(): |
There was a problem hiding this comment.
to do - rename this to match task name
| .filter(*filters) | ||
| .update( | ||
| { | ||
| "notification_count": func.greatest(FactServiceStats.notification_count + change_count, 0), |
There was a problem hiding this comment.
Should we error if change_count is bigger than notification_count as this shouldn't happen?
There was a problem hiding this comment.
Note: We may need to test what happens if the row doesn't exist at all
| AND pid = pg_backend_pid() | ||
| AND granted | ||
| AND classid = CAST((CAST(:lock_id AS bigint) >> 32) AS integer) | ||
| AND objid = CAST((CAST(:lock_id AS bigint) & 4294967295) AS integer) |
There was a problem hiding this comment.
4294967295
^^ document what this means
|
|
||
|
|
||
| def _extract_row_data(change: dict[str, Any]) -> RowData: | ||
| if "columnnames" in change and "columnvalues" in change: |
There was a problem hiding this comment.
This is only used in format v1 therefore we can remove now
| if "identity" in change and change.get("action") in {"D", "U", "I"}: | ||
| return _extract_name_value_rows(change["identity"]) |
There was a problem hiding this comment.
not needed for insert
| oldkeys = change.get("oldkeys") or {} | ||
| if "keynames" in oldkeys and "keyvalues" in oldkeys: | ||
| return _zip_values(oldkeys["keynames"], oldkeys["keyvalues"]) | ||
|
|
||
| if "keys" in oldkeys: | ||
| return _extract_name_value_rows(oldkeys["keys"]) |
| if change.get("lsn"): | ||
| last_lsn = change["lsn"] | ||
| elif change.get("nextlsn"): | ||
| last_lsn = change["nextlsn"] |
There was a problem hiding this comment.
This may be able to refactor out
| if table_name != REPLICATION_SLOT_TABLE_NAME.split(".")[-1]: | ||
| ignored_changes += 1 | ||
| continue |
There was a problem hiding this comment.
This shouldn't ever happen - so can be removed
| # If the key_type is "test", we ignore this change and return None to indicate | ||
| # that it should not be processed further. | ||
| if key_type == "test": | ||
| return None |
There was a problem hiding this comment.
Potentially could be refactored to happen at an earlier stage
| if old_dimensions: | ||
| counter[old_dimensions] -= 1 | ||
| updated = True |
There was a problem hiding this comment.
If no old dimension - we should continue because we don't want to increase the same status again
This will be replaced with the actual task in the following commits
the class is not processing all replication slot changes - just notifications
These are not needed
…eplication slot changes
Also include bst_date in the dimensions
…t stats updates and slot advancement in a single transaction
…eplication slot accordingly
… advancement and update related tests
This is to avoid unnessary calls
10 seconds sometimes feels delayed for users
29d32f3 to
a1c7a1f
Compare
** DO NOT MERGE UNTIL #4946 IS MERGED IN FIRST**
What
The application code for processing slot changes for notifications table
Why
This is needed to process WAL logs in the database
Test results
Ran a load test on
dev-c- this is the result after 2400 emails.How it works