-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add PostgreSQL support for rollback backend #16757
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
johnnyjoy
wants to merge
12
commits into
luanti-org:master
Choose a base branch
from
johnnyjoy:pr/rollback-postgresql
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+1,925
−781
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sfan5
requested changes
Dec 18, 2025
Member
sfan5
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rollback code is a bit neglected, but surprisingly many people still use it and I guess adding another backend is okay.
sfan5
reviewed
Dec 25, 2025
SmallJoker
reviewed
Dec 28, 2025
SmallJoker
reviewed
Dec 31, 2025
058d001 to
ddcb9a3
Compare
Extract the large cache loading blocks from RollbackManagerPostgreSQL constructor into loadActorCache() and loadNodeCache() helper methods. This reduces the constructor from ~33 lines to 5 lines, addressing sfan5's feedback about large code blocks.
Co-authored-by: SmallJoker <[email protected]>
Co-authored-by: SmallJoker <[email protected]>
Improve error handling in Server::createRollbackManager - Throw exception if world.mt cannot be read, matching openModStorageDatabase pattern - Remove unused backend_source variable and simplify logging - Simplify backend selection using world_mt.getNoEx() instead of if-else block Enhance error messages and help output - Add Server::getRollbackBackends() to dynamically list available backends - Use dynamic backend list in error message for unsupported backends - Add rollback backends to print_help() output in main.cpp - Remove redundant USE_POSTGRESQL=OFF specific error message Improve destructor safety and consistency - Move db != nullptr check from SQLite destructor to flush() method - Move initialized() check from PostgreSQL destructor to flush() method - Ensures consistent safety checks across both backends Restore spacing alignment for readability - Add space padding after sqlite3_bind_* function names - Matches existing pattern in rollback_sqlite3.cpp Rename RollbackManager to RollbackMgr for line length compliance - Use RollbackMgr abbreviation following existing codebase patterns - Rename RollbackManager → RollbackMgr - Rename RollbackManagerSQLite3 → RollbackMgrSQLite3 - Rename RollbackManagerPostgreSQL → RollbackMgrPostgreSQL - Break long function signatures to ensure all lines are under 95 characters
…ng bool The original code would throw std::out_of_range when substr() was called with npos, making the fallback code that bound 0,0,0 unreachable dead code. This change makes parseNodemetaLocation() throw std::invalid_argument on invalid format, matching the original behavior and eliminating the dead code. Changes: Change parseNodemetaLocation() signature from bool to void Throw std::invalid_argument exceptions instead of returning false Remove unreachable fallback blocks in SQLite and PostgreSQL backends Add #include <stdexcept> to rollback.cpp This addresses SmallJoker's feedback.
Address SmallJoker's request for unit tests to verify that parseNodemetaLocation() correctly throws std::invalid_argument on invalid format. Tests cover: Valid format parsing (basic, negative, zero coordinates) Invalid format exceptions (missing prefix, missing commas, empty string)
5a0716d to
3cb71ba
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Action / change needed
Code still needs changes (PR) / more information requested (Issues)
Feature ✨
PRs that add or enhance a feature
Roadmap: supported by core dev
PR not adhering to the roadmap, yet some core dev decided to take care of it
@ Startup / Config / Util
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds PostgreSQL as an optional backend for the rollback system, complementing the existing SQLite3 implementation. The rollback backend is configurable per-world via
rollback_backendinworld.mt, defaulting tosqlite3when unset.Changes
RollbackMgrPostgreSQL) with feature parity to SQLite3pgsql_rollback_connectionwhen PostgreSQL is selected (no fallback to map backend)RollbackMgr) to eliminate code duplication between backendsServer::init()intoServer::createRollbackManager()doc/world_format.mdandbuiltin/settingtypes.txtupdatedConfiguration
Set in
world.mt:rollback_backend = postgresql(orsqlite3)pgsql_rollback_connection = "host=... dbname=..."(required when using PostgreSQL)Development Process
This PR was developed with assistance from Cursor and LLM tools for code generation and refactoring. All changes have been reviewed against project coding standards, and feedback from maintainers (sfan5, SmallJoker) has been incorporated throughout the development process.