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

Rewrite RR cache access time update to preserve table insert order #7578

Conversation

RaimoNiskanen
Copy link
Contributor

@RaimoNiskanen RaimoNiskanen commented Aug 22, 2023

The cache ETS table is a bag table that in itself preserves insert order, and when access times in the table are update, it is possible to do the insertion of RRs with updated access time in the same order, which overall preserves insert order.

To preserve the RR order; rewrite the deduplication code to not store the deduplicated result in a map, but instead use a map for deduplication lookup and store the result in a list.

All this to not get in the way of DNS servers that e.g. implement load balancing by returning RRs in some specific order.

Closes #7577

The cache ETS table is a bag table that in itself preserves insert order,
and when access times in the table are update, it is possible to
do the insertion of RRs with updated access time in the same order,
which overall preserves insert order.

To preserve the RR order; rewrite the deduplication code to not store
the deduplicated result in a map, but instead use a map for deduplication
lookup and store the result in a list.

All this to not get in the way of DNS servers that e.g. implement load balancing
by returning RRS in some specific order.
@RaimoNiskanen RaimoNiskanen added team:PS Assigned to OTP team PS fix bug Issue is reported as a bug priority:medium labels Aug 22, 2023
@RaimoNiskanen RaimoNiskanen added this to the OTP-26.1 milestone Aug 22, 2023
@RaimoNiskanen RaimoNiskanen self-assigned this Aug 22, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 22, 2023

CT Test Results

       2 files       65 suites   1h 1m 15s ⏱️
1 494 tests 1 250 ✔️ 243 💤 1
1 685 runs  1 394 ✔️ 290 💤 1

For more details on these failures, see this check.

Results for commit 49e7325.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@starbelly
Copy link
Contributor

starbelly commented Aug 22, 2023

@RaimoNiskanen LGTM! I was quite convinced there was an edge case that would not afford simply switching to list for everything to just work ™️ Thanks for showing me otherwise ❤️

Edit:

I fired off too quick bad instrumentation. Let me double check things again, but I'm seemingly still ending up with a sorted list of entries.

@starbelly
Copy link
Contributor

Ok, double checked, triple checked even 😄, and it looks solid 👍

Here's a gist of the test.

@RaimoNiskanen
Copy link
Contributor Author

It would also be nice if @mattbaker could verify that it solves his #7577, and if @sneako could verify that his heavy load cache tests does not suffer regression...

@sneako
Copy link
Contributor

sneako commented Aug 22, 2023

It would also be nice if @mattbaker could verify that it solves his #7577, and if @sneako could verify that his heavy load cache tests does not suffer regression...

Wow, exciting! Thank you for working on this. I just got back from vacation so I have a bit of catch up to do, but I will make sure to test this out this week.

@mattbaker
Copy link

First time compiling Erlang but I think I got it 😅

I can confirm that records no longer appear sorted with this patch, looks like a success to me 👍

@sneako
Copy link
Contributor

sneako commented Aug 25, 2023

I've been running this patch on a single node in a cluster for 2 hours so far and performance looks identical to the unpatched peers. Have not noticed any adverse side effects. LGTM, thanks everyone!

@RaimoNiskanen RaimoNiskanen merged commit f03c24f into erlang:maint Aug 28, 2023
14 of 16 checks passed
@RaimoNiskanen RaimoNiskanen deleted the raimo/kernel/inet_dns-stable-cache/GH-7577/OTP-18731 branch August 28, 2023 12:21
@RaimoNiskanen RaimoNiskanen linked an issue Aug 28, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug fix priority:medium team:PS Assigned to OTP team PS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DNS caching causes host records to be returned in sorted order
4 participants