Skip to content
New issue

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

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

Already on GitHub? # to your account

mnesia_to_khepri: Check record validity before calling Mod:copy_to_khepri/3 #8

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

dumbbell
Copy link
Member

Why

It appears that we get Mnesia write events with the table name and the key, instead of the table name and the written record. The expected event seems to come after.

We can't do anything with just the key and we want to skip calls to the callback module in this case.

How

To distinguish the key from the expected record, we first query the table info to get the record name and its arity. Then, we verify the received term against the queried record definition to check if the term is a valid record before calling Mod:copy_to_khepri/3.

@dumbbell dumbbell added the enhancement New feature or request label Oct 27, 2023
@dumbbell dumbbell added this to the v0.2.1 milestone Oct 27, 2023
@dumbbell dumbbell requested a review from dcorbacho October 27, 2023 09:58
@dumbbell dumbbell self-assigned this Oct 27, 2023
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (6a56ade) 75.39% compared to head (4207644) 75.49%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
+ Coverage   75.39%   75.49%   +0.10%     
==========================================
  Files          13       13              
  Lines         634      657      +23     
==========================================
+ Hits          478      496      +18     
- Misses        156      161       +5     
Flag Coverage Δ
erlang-25 75.03% <79.16%> (+0.11%) ⬆️
erlang-26 75.49% <79.16%> (+0.10%) ⬆️
os-ubuntu-latest 75.49% <79.16%> (+0.10%) ⬆️
os-windows-latest 75.49% <79.16%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/m2k_table_copy.erl 76.01% <79.16%> (+0.20%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dumbbell dumbbell force-pushed the ignore-non-records-in-copy_to_khepri branch 3 times, most recently from e6a7cdd to 6c8902a Compare October 27, 2023 12:05
…hepri/3`

[Why]
It appears that we get Mnesia write events with the table name and the
key, instead of the table name and the written record. The expected
event seems to come after.

We can't do anything with just the key and we want to skip calls to the
callback module in this case.

[How]
To distinguish the key from the expected record, we first query the
table info to get the record name and its arity. Then, we verify the
received term against the queried record definition to check if the term
is a valid record before calling `Mod:copy_to_khepri/3`.
@dumbbell dumbbell force-pushed the ignore-non-records-in-copy_to_khepri branch from 6c8902a to 4207644 Compare October 27, 2023 12:16
@dumbbell dumbbell marked this pull request as ready for review October 27, 2023 13:31
@dumbbell dumbbell merged commit a3e26de into main Oct 27, 2023
@dumbbell dumbbell deleted the ignore-non-records-in-copy_to_khepri branch October 27, 2023 13:31
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant