Skip to content

MCOL-5861 cmapi read only nodes #3432

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

Open
wants to merge 13 commits into
base: stable-23.10
Choose a base branch
from

Conversation

mariadb-AlexanderPresniakov
Copy link
Contributor

@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov commented Mar 12, 2025

https://jira.mariadb.org/browse/MCOL-5861
Read-only nodes don't start WriteEngineServer and do not own dbroots. But as read-only nodes must have RO access to all the data in the cluster, all dbroots in the cluster are assigned all the dbroots.
Read-only nodes are written into ReadOnlyNodes part of the config.
On every change that could add or remove dbroots update_dbroots_of_readonly_nodes is called to assign all existing dbroots to every read-only node.

MCSProgs was added to avoid possible typos in service names (because there is no single naming convention between services and it is very easy to make an error)
Also added NodeConfig.modify_config context manager that reads config from specified path, provides its root and on (only successful exit) writes config to the output path

@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov marked this pull request as draft March 12, 2025 13:23
@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov force-pushed the MCOL-5806-cmapi-read-only-nodes branch 8 times, most recently from bbd12b4 to 728d94d Compare March 18, 2025 12:54
@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov force-pushed the MCOL-5806-cmapi-read-only-nodes branch 3 times, most recently from e698ef4 to a74b938 Compare March 28, 2025 03:53
@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov marked this pull request as ready for review March 28, 2025 03:55
@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov changed the title MCOL-5806 cmapi read only nodes MCOL-5861 cmapi read only nodes Mar 28, 2025
@mariadb-AlanMologorsky
Copy link
Contributor

Name branch as a feature/MCOL-.....
And the same about unified commits pls.

Short description is better than just JIRA link. Even summary from commit\s message.

@mariadb-AlanMologorsky
Copy link
Contributor

And one thing about NEW readonly node naming - Seems should be discussed together with @drrtuy or @mariadb-LeonidFedorov or both.
Because comparing to any "readonly" mention in previous code this naming could be confusing.

@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov force-pushed the MCOL-5806-cmapi-read-only-nodes branch from a74b938 to 220f03f Compare March 31, 2025 19:39
@mariadb-AlanMologorsky mariadb-AlanMologorsky force-pushed the MCOL-5806-cmapi-read-only-nodes branch from 3ca8a6f to 2bd07e4 Compare April 2, 2025 18:53
@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov force-pushed the MCOL-5806-cmapi-read-only-nodes branch 3 times, most recently from 481d491 to 44ae561 Compare April 14, 2025 15:31
@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov force-pushed the MCOL-5806-cmapi-read-only-nodes branch 2 times, most recently from 4ce4e78 to 1833abc Compare April 23, 2025 19:32
@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov force-pushed the MCOL-5806-cmapi-read-only-nodes branch from db91612 to 5359c98 Compare April 28, 2025 15:20
@mariadb-AlexanderPresniakov mariadb-AlexanderPresniakov force-pushed the MCOL-5806-cmapi-read-only-nodes branch from a73579a to e7fd6fc Compare April 28, 2025 19:21
@@ -104,7 +104,8 @@ def enable_console_logging(logger: logging.Logger) -> None:
def config_cmapi_server_logging():
# add custom level TRACE only for develop purposes
# could be activated using API endpoints or cli tool without relaunching
add_logging_level('TRACE', 5)
if not hasattr(logging, 'TRACE'):
add_logging_level('TRACE', 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

JFYI I think to remove or rewrite this dev function.

@@ -89,7 +98,8 @@ def _detect_processes(cls) -> None:
if cls.mcs_progs:
logging.warning('Mcs ProcessHandler already detected processes.')

for prog_name, prog_info in ALL_MCS_PROGS.items():
for prog, prog_info in ALL_MCS_PROGS.items():
prog_name = prog.value
Copy link
Contributor

Choose a reason for hiding this comment

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

JFYI It's what I mentioned before here about naming and access names. prog.value == prog_name. It's somehow confusing.

CMAPI_CONF_PATH,
CMAPI_SINGLE_NODE_XML,
DEFAULT_MCS_CONF_PATH,
LOCALHOSTS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need it on a separate lines?


def update_dbroots_of_readonly_nodes(root: etree.Element) -> None:
"""Read-only nodes do not have their own dbroots, but they must have all the dbroots of the other nodes
So this function sets list of dbroots of each read-only node to the list of all the dbroots in the cluster
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to be vice versa.
sets list of all the dbroots in the cluster to the list of dbroots of each read-only node

)
dbroot_id_node.text = str(dbroot_id)

logging.info("Added %d dbroots to read-only node %d: %s", len(existing_dbroots), module_num, sorted(existing_dbroots))
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls f-string notation.

logging.basicConfig(level='DEBUG')

SINGLE_NODE_XML = "./cmapi_server/SingleNode.xml"
Copy link
Contributor

Choose a reason for hiding this comment

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

JFYI I'm not sure that default Columnstore.xml is fully equal to SingleNode.xml

)

with patch('cmapi_server.node_manipulation.update_dbroots_of_readonly_nodes') as mock_update_dbroots_of_readonly_nodes:
node_manipulation.add_node(
Copy link
Contributor

Choose a reason for hiding this comment

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

With this mock test name is not fully valid. Here we test add\remove node and mocked function call once.
May be better to move it in separate test?

self.NEW_NODE_NAME, self.tmp_files[1], self.tmp_files[2],
test_mode=True
)
mock_update_dbroots_of_readonly_nodes.assert_called_once()
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear to me what we trying to test here several times. Several times test that we call the mocked function once?

@@ -137,6 +138,26 @@ def write_config(self, tree, filename=DEFAULT_MCS_CONF_PATH):
f.write(self.to_string(tree))
replace(tmp_filename, filename) # atomic replacement

@contextmanager
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to move it in separate PR and integrate in other places tho.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this file?

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.

2 participants