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

Add hook functions for xlog, allow custom Table-AM to implement custom wal. #848

Conversation

gongxun0928
Copy link
Contributor

@gongxun0928 gongxun0928 commented Jan 7, 2025

Add two hook functions for extension, make custom Table-Am can hook in xlog redo

typedef void (*ConsistencyCheck_hook_type) (void);
extern PGDLLIMPORT ConsistencyCheck_hook_type xlog_check_consistency_hook;

typedef void (*XLOGDropDatabase_hook_type)(Oid dbid);
extern XLOGDropDatabase_hook_type XLOGDropDatabase_hook;

In cloudberrydb, when mirror instance redo xlog, StartupXLog will start replaying from the
latest checkpoint's REDO location in pg_control. When processing the xlog of data writing,
we need to write the data in xlog into the data file, but the entire db directory may be deleted
due to the drop database xlog that has been replayed last time.

XLogDropDatabase and XLogCheckInvalidPages limits the table to be organized in page mode.
For custom Table-Am, their data organization is not necessarily in page mode.

We need to provide a hook for the implementation of custom wal log to handle this situation.
master:
\c testdb
t1: create table t1(a int);
t2: select pg_sleep(checkpoint_timeout); --wait checkpoint_timeout, do checkpoint on mirror;
t3: insert into t1 select generate_series(1,10);
t4: dropdb testdb
t5: pkill postgres -- mirror should redo dropdb and not do next checkpoint on mirror

then we restart the cluster, mirror will recovery restart at the xlog of insert sql, but the data path of testdb has been deleted

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


@my-ship-it my-ship-it requested a review from gfphoenix78 January 7, 2025 12:20
@my-ship-it my-ship-it merged commit 8da7660 into apache:main Jan 8, 2025
43 of 45 checks passed
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