Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Ensure multi delete specs dont terminate half way through#620

Merged
kjnilsson merged 1 commit into
mainfrom
mt-cleanup-fixes
Apr 17, 2026
Merged

Ensure multi delete specs dont terminate half way through#620
kjnilsson merged 1 commit into
mainfrom
mt-cleanup-fixes

Conversation

@kjnilsson
Copy link
Copy Markdown
Contributor

@kjnilsson kjnilsson commented Apr 16, 2026

Fix memtable multi-spec deletion and improve snapshot error handling

This commit addresses several issues across memtable cleanup and snapshotting:

  • ra_mt: Update delete({multi, Specs}) to catch badarg exceptions. This ensures that if an ETS table in the spec was already deleted (e.g., by an accelerated cleanup or another operation), the deletion process gracefully skips it and continues with the remaining specs instead of crashing.
  • ra_server_proc: Enhance error handling in send_snapshots/9 by wrapping send_pre_snapshot_entries in a try...catch block to log errors and safely re-raise them using safe_stacktrace/1. Also improves log formatting and clarifies UID pattern matching.
  • ra_log_segments: Fix a format specifier mismatch in a warning log (changed ~w to ~b and added ~0P for segment references).
  • ra_mt_SUITE: Add the multi_spec_delete_with_missing_tid test to verify the new resilient multi-spec deletion behavior.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent multi-spec delete operations from aborting early when one delete spec fails (e.g., due to an ETS table already being deleted), and adds coverage for that scenario.

Changes:

  • Make ra_mt:delete({multi, Specs}) resilient to badarg so remaining specs are still processed.
  • Add a new Common Test case to exercise “missing Tid in multi delete” behavior.
  • Improve warning logging in ra_log_segments:segment_read_plan/4 to include segref count and a bounded pretty-print of remaining segrefs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
test/ra_mt_SUITE.erl Adds a regression test for multi-spec delete when one Tid is missing.
src/ra_mt.erl Wraps multi-spec delete execution to continue after badarg.
src/ra_log_segments.erl Updates warning log message/format for missing read plan segrefs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ra_mt.erl Outdated
Comment thread test/ra_mt_SUITE.erl
Comment thread src/ra_log_segments.erl Outdated
Comment thread src/ra_mt.erl
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to ensure ra_mt:delete/1 can process multi-delete specs without terminating early when one of the referenced ETS tables has already been deleted (missing Tid).

Changes:

  • Add a regression test covering multi-spec delete behavior when an earlier Tid is missing.
  • Make ra_mt:delete({multi, Specs}) resilient to badarg errors during per-spec deletion.
  • Improve warning context in ra_log_segments:segment_read_plan/4 when indexes can’t be found.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/ra_mt_SUITE.erl Adds a test ensuring multi-spec delete continues after encountering a missing Tid.
src/ra_mt.erl Wraps per-spec deletion in try/catch to skip badarg and continue folding remaining specs.
src/ra_log_segments.erl Expands WARN log details for missing indexes/segment refs (but currently has a formatting issue).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ra_mt.erl
Comment thread src/ra_log_segments.erl Outdated
Copy link
Copy Markdown

Copilot AI commented Apr 16, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.hex.pm
    • Triggering command: /usr/bin/curl curl -Lfso /home/REDACTED/work/ra/ra/.erlang.mk/hex/aten.tar REDACTED (dns block)
    • Triggering command: /usr/bin/curl curl -Lfso /home/REDACTED/work/ra/ra/.erlang.mk/hex/gen_batch_server.tar REDACTED (dns block)
    • Triggering command: /usr/bin/curl curl -Lfso /home/REDACTED/work/ra/ra/.erlang.mk/hex/seshat.tar REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent multi-spec memtable delete operations from terminating early when one of the delete specs hits an error (e.g., an ETS table in the spec has already been deleted).

Changes:

  • Adds a new Common Test case covering multi-spec delete behavior when an earlier {delete, Tid} refers to a missing ETS table.
  • Updates ra_mt:delete/1 for {multi, Specs} to tolerate badarg during per-spec deletion rather than aborting the whole fold.
  • Tweaks a warning log in ra_log_segments:segment_read_plan/4 to include additional context about remaining segrefs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/ra_mt_SUITE.erl Adds coverage to ensure multi-spec delete continues after an earlier missing-Tid failure.
src/ra_mt.erl Wraps per-spec delete in a try/catch so one failing spec doesn’t stop subsequent specs.
src/ra_log_segments.erl Expands warning log context for missing segment refs during read plan creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ra_mt.erl
Comment thread src/ra_log_segments.erl Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to ensure multi-spec deletion in ra_mt continues executing remaining delete specs even if one spec fails (e.g., when an ETS table has already been deleted).

Changes:

  • Add a CT test that simulates a “missing ETS tid” during multi-spec deletion and asserts later specs still run.
  • Update ra_mt:delete/1 for {multi, Specs} to tolerate badarg during per-spec deletion.
  • Adjust a warning log format in ra_log_segments:segment_read_plan/4.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/ra_mt_SUITE.erl Adds a regression test covering multi-spec delete behavior when a referenced ETS table is missing.
src/ra_mt.erl Wraps per-spec deletes in try/catch so multi deletes continue after a badarg.
src/ra_log_segments.erl Tweaks warning log formatting / contents for missing-index read plan scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ra_mt.erl
Comment thread src/ra_log_segments.erl
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent multi-spec deletion from terminating early when one spec fails (e.g., an ETS table has already been deleted), improving robustness of memtable cleanup.

Changes:

  • Add a regression test covering multi-spec delete behavior when an earlier {delete, Tid} target is missing.
  • Update ra_mt:delete/1 for {multi, Specs} to continue processing after a badarg during an individual spec delete.
  • Minor snapshot-send error handling/logging adjustments and a log formatting tweak in segment read planning.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/ra_mt_SUITE.erl Adds multi_spec_delete_with_missing_tid to validate multi-spec delete continues after an earlier missing-Tid failure.
src/ra_mt.erl Wraps per-spec deletion in try/catch so one badarg doesn’t abort the entire multi delete.
src/ra_server_proc.erl Adds a try/catch around send_pre_snapshot_entries/6 and log formatting changes in snapshot send path.
src/ra_log_segments.erl Tweaks WARN formatting to include remaining segref count and pretty-print segrefs with a depth limit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ra_mt.erl
Comment thread src/ra_server_proc.erl Outdated
@kjnilsson kjnilsson force-pushed the mt-cleanup-fixes branch 2 times, most recently from b938cd2 to 74acd5a Compare April 16, 2026 14:19
This commit addresses several issues across memtable cleanup and snapshotting:

- `ra_mt`: Update `delete({multi, Specs})` to catch `badarg` exceptions. This ensures that if an ETS table in the spec was already deleted (e.g., by an accelerated cleanup or another operation), the deletion process gracefully skips it and continues with the remaining specs instead of crashing.
- `ra_server_proc`: Enhance error handling in `send_snapshots/9` by wrapping `send_pre_snapshot_entries` in a `try...catch` block to log errors and safely re-raise them using `safe_stacktrace/1`. Also improves log formatting and clarifies `UID` pattern matching.
- `ra_log_segments`: Fix a format specifier mismatch in a warning log (changed `~w` to `~b` and added `~0P` for segment references).
- `ra_mt_SUITE`: Add the `multi_spec_delete_with_missing_tid` test to verify the new resilient multi-spec deletion behavior.
@kjnilsson kjnilsson marked this pull request as ready for review April 16, 2026 15:30
@mkuratczyk mkuratczyk self-requested a review April 16, 2026 16:31
@kjnilsson kjnilsson merged commit c942574 into main Apr 17, 2026
8 checks passed
@kjnilsson kjnilsson deleted the mt-cleanup-fixes branch April 17, 2026 06:19
@michaelklishin michaelklishin added this to the 3.1.5 milestone Apr 17, 2026
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.

5 participants