Skip to content

Conversation

Mikaka27
Copy link
Contributor

@Mikaka27 Mikaka27 commented Aug 29, 2025

The problem is that mnesia_decision table stores multiple tuple/record types, and the key is on position 2.
What can be stored:

  • {mnesia_down, Node, Date, Time}
  • {master_nodes, Tab, Nodes}
  • -record(decision, {tid, outcome, disc_nodes, ram_nodes}).
  • {trans_tid, serial, Serial}

If table name is equal to node name, the {mnesia_down, ...} and {master_nodes, ...} can conflict with each other, and {mnesia_down, ...} can be interpreted as {master_nodes, ...} causing crash in mnesia.

@Mikaka27 Mikaka27 changed the title Michal/mnesia/fix-handling-node-name-as-atom-name/otp-19745 Michal/mnesia/fix-handling-node-name-as-table-name/otp-19745 Aug 29, 2025
Copy link
Contributor

github-actions bot commented Aug 29, 2025

CT Test Results

  2 files   61 suites   19m 17s ⏱️
694 tests 543 ✅ 151 💤 0 ❌
749 runs  583 ✅ 166 💤 0 ❌

Results for commit 0c8f423.

♻️ 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

@Mikaka27 Mikaka27 requested a review from Copilot August 29, 2025 13:27
Copy link

@Copilot 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 fixes a bug in Mnesia where using a node name as a table name could cause crashes due to conflicting keys in the mnesia_decision table. The fix wraps node names and table names with tagged tuples to ensure unique keys.

  • Changes the key format in mnesia_decision table from raw names to tagged tuples ({node, Node} and {tab, Tab})
  • Updates all related functions to handle the new key format consistently
  • Adds conversion functions for backward compatibility with disk format
  • Includes a regression test to verify the fix

Reviewed Changes

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

File Description
lib/mnesia/src/mnesia_recover.erl Implements the core fix by wrapping node/table names in tagged tuples and adding conversion functions
lib/mnesia/test/mnesia_recovery_test.erl Adds regression test to verify node names can be used as table names

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Mikaka27 Mikaka27 self-assigned this Aug 29, 2025
@Mikaka27 Mikaka27 added team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI labels Aug 29, 2025
@Mikaka27 Mikaka27 requested a review from dgud September 1, 2025 11:03
@Mikaka27 Mikaka27 merged commit 07c979d into erlang:maint Sep 8, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants