Skip to content

[HA] An empty replica breaks when asks for a full resync#2595

Merged
lvca merged 5 commits intoArcadeData:mainfrom
carlos-rodrigues-8x8:fix/2594-fixing-full-resynch
Oct 8, 2025
Merged

[HA] An empty replica breaks when asks for a full resync#2595
lvca merged 5 commits intoArcadeData:mainfrom
carlos-rodrigues-8x8:fix/2594-fixing-full-resynch

Conversation

@carlos-rodrigues-8x8
Copy link
Contributor

@carlos-rodrigues-8x8 carlos-rodrigues-8x8 commented Oct 3, 2025

What does this PR do?

This PR is meant to fix a bug on full synch request on HA mode, as described in the open issue.

Motivation

Contributing for evolving arcadedb.

Related issues

#2594

Additional Notes

Checklist

  • I have run the build using mvn clean package command
  • My unit tests cover both failure and success scenarios

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @carlos-rodrigues-8x8, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug affecting High Availability (HA) mode where an empty replica would encounter an error during a full resynchronization process. The primary fix involves a more robust method for retrieving file components, preventing failures in scenarios where files might not be immediately present. Additionally, a minor refinement was made to the server startup script for improved argument handling.

Highlights

  • HA Full Resync Bug Fix: Addresses a critical bug where an empty replica would fail during a full synchronization request in High Availability (HA) mode, ensuring smoother data replication.
  • Robust File Component Retrieval: Improved the retrieval of paginated components in PageManager.java by switching from getFileById to getFileByIdIfExists, preventing potential errors when a file might not be present.
  • Server Startup Script Refinement: Corrected argument passing in the server.sh script by removing the redundant $*, ensuring proper and consistent handling of command-line arguments.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug in High Availability mode and improves the server startup script. The change in PageManager.java makes the page flushing process more robust by using getFileByIdIfExists, which prevents exceptions when a file does not exist, a scenario that can occur during HA synchronization. The change in server.sh corrects the handling of command-line arguments by removing a redundant parameter that caused arguments to be duplicated. Both changes are correct and improve the codebase. I have one suggestion for the shell script to further improve its robustness regarding argument handling.

$ARCADEDB_SETTINGS \
-cp "$ARCADEDB_HOME/lib/*" \
$ARGS $* "$@" com.arcadedb.server.ArcadeDBServer
$ARGS "$@" com.arcadedb.server.ArcadeDBServer
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While removing the redundant $* is the correct fix for duplicated arguments, the use of unquoted $ARGS on this line can be fragile. If a user sets $ARGS to a value containing spaces that should be preserved within a single argument (e.g., a path), shell word-splitting will break it. For example, ARGS='-Dmy.prop="some value"' would be incorrectly passed to the Java process.

This is a common limitation in sh scripts. If it's not feasible to switch to bash and use arrays for robust argument handling, it would be beneficial to add a comment to the script documenting that variables like $ARGS should not contain values with spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed used variable

Copy link
Collaborator

@gramian gramian Oct 8, 2025

Choose a reason for hiding this comment

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

We need to tightly review this change. I remember experimenting with that before and it led to problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which change @gramian? Removing $* or $ARGS?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Removing $*

Copy link
Contributor Author

@carlos-rodrigues-8x8 carlos-rodrigues-8x8 Oct 8, 2025

Choose a reason for hiding this comment

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

Both $* $@ are doing the same thing. Doesn't make sense to have both in the command. The slightly difference between both is $* expands to a single string containing all arguments separated by a space, while $@ is an array, but we are using it as string since it is between ". If you feel comfortable I can change to use $*.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can try, we just need to test if the various shells (including MacOS) support both, or if there are corner cases where it could break.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately I don't remember what the problem was, but I was using the same reasoning as you above.

@lvca lvca requested a review from robfrank October 3, 2025 23:23
@lvca lvca added the bug label Oct 3, 2025
@lvca lvca added this to the 25.9.1 milestone Oct 3, 2025
@robfrank robfrank modified the milestones: 25.9.1, 25.10.1 Oct 7, 2025
@robfrank robfrank requested a review from lvca October 8, 2025 09:42
$ARCADEDB_SETTINGS \
-cp "$ARCADEDB_HOME/lib/*" \
$ARGS $* "$@" com.arcadedb.server.ArcadeDBServer
"$@" com.arcadedb.server.ArcadeDBServer
Copy link
Contributor

Choose a reason for hiding this comment

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

@robfrank this looks fine to me, not sure about this change in the script. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I explained before to @gramian, both $* and $@ doing the same thing, we are just duplicating the parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted! Should I open another ticket to handle it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please, thanks!

Copy link
Contributor

@lvca lvca left a comment

Choose a reason for hiding this comment

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

This is ok for me, not sure about the change in the server.sh

@robfrank
Copy link
Collaborator

robfrank commented Oct 8, 2025

@carlos-rodrigues-8x8 could you please remove the change to server.sh?
Then I'll merge it.

@lvca
Copy link
Contributor

lvca commented Oct 8, 2025

Thanks @carlos-rodrigues-8x8 !

@lvca lvca merged commit fc1d7a1 into ArcadeData:main Oct 8, 2025
11 of 13 checks passed
@lvca lvca modified the milestones: 25.10.1, 25.9.1 Oct 8, 2025
robfrank added a commit that referenced this pull request Nov 5, 2025
robfrank pushed a commit that referenced this pull request Nov 10, 2025
* Adding fix for full sync request

* Cosmetic patch to avoid duplication of configurations

* Reverting deleted lines

* Removing unused variable

* Reverting server.sh

(cherry picked from commit fc1d7a1)
robfrank added a commit that referenced this pull request Nov 10, 2025
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.

4 participants