feat(sql): add journal event persistence - #954
Open
bercianor wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds SQL-backed “journal event” persistence to complement the existing SQL audit log, enabling stage-scoped journal streams while keeping the audit table as the current-state store. It also tightens SQL transaction session lifecycle handling and aligns the SQL external-system API with other transactional target systems.
Changes:
- Introduces a SQL Journal Event store (schema helper + mapper) and journal-aware SQL audit persistence that appends journal events and updates current state in one transaction.
- Refactors
SqlAuditStoreto provide stage-scoped persistence viagetPersistenceFactory()and adds repository name validation (audit/lock/journal). - Updates SQL transaction wrapper session lifecycle (
closeSession) and adds/extends tests covering journaling behavior and SQL transaction wrapper behavior.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| core/target-systems/flamingock-sql-targetsystem/src/test/java/io/flamingock/targetsystem/sql/SqlTxWrapperLifecycleTest.java | New test coverage for SQL tx wrapper commit/rollback and session reuse. |
| core/target-systems/flamingock-sql-targetsystem/src/main/java/io/flamingock/targetsystem/sql/SqlTxWrapper.java | Closes transaction sessions in a finally block to avoid reusing closed sessions. |
| core/target-systems/flamingock-sql-externalsystem-api/src/main/java/io/flamingock/externalsystem/sql/api/SqlExternalSystem.java | Aligns SQL external system API with transactional external systems by exposing getTxWrapper(). |
| core/target-systems/flamingock-sql-externalsystem-api/build.gradle.kts | Adjusts dependencies to expose core-commons types to consumers of the external-system API. |
| community/flamingock-sql-auditstore/src/test/java/io/flamingock/store/sql/SqlAuditTestHelper.java | Updates test schema helper to include the new journal table and adjusts dialect-specific DDL. |
| community/flamingock-sql-auditstore/src/test/java/io/flamingock/store/sql/SqlAuditStoreTest.java | Adds tests validating journal-enabled behavior, repository naming rules, and feature-flag snapshot behavior. |
| community/flamingock-sql-auditstore/src/test/java/io/flamingock/store/sql/PipelineTestHelper.java | Removes a local test helper (pipeline preview builder). |
| community/flamingock-sql-auditstore/src/test/java/io/flamingock/store/sql/internal/SqlJournalEventStoreJdbcTest.java | New JDBC tests for schema creation/validation, append/read/ack flows, and failure cases. |
| community/flamingock-sql-auditstore/src/test/java/io/flamingock/store/sql/internal/SqlJournalEventMapperTest.java | New unit tests for journal event ↔ row mapping, including nullable handling and dialect null types. |
| community/flamingock-sql-auditstore/src/test/java/io/flamingock/store/sql/internal/SqlJournalDialectHelperTest.java | New tests asserting portable schema generation and deterministic index naming across dialects. |
| community/flamingock-sql-auditstore/src/test/java/io/flamingock/store/sql/internal/SqlAuditPersistenceJournalTest.java | New tests validating journal-enabled write ordering, rollback semantics, and sequencing guarantees. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/SqlAuditStore.java | Refactors to stage-scoped persistence, adds journal store wiring, and validates repository naming. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/SqlLockService.java | Makes lock table initialization idempotent by checking existence before creating. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/SqlJournalEventStore.java | Adds the JDBC implementation of journal buffering + schema validation + acknowledgements. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/SqlJournalEventMapper.java | Adds binder/reader for journal event envelope + flattened audit payload. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/SqlJournalDialectHelper.java | Adds dialect-aware DDL/DML generation and index naming limits/strategy. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/SqlAuditRepository.java | New audit repository used for both append-only history and current-state replacement operations. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/SqlAuditPersistence.java | Journal-aware persistence: append event + update current state transactionally, confirm sequencer on success. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/SqlAuditor.java | Removes legacy auditor implementation in favor of the new repository/mapper approach. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/JournalEventConstants.java | Adds shared SQL identifier validation and journal naming constants. |
| community/flamingock-sql-auditstore/src/main/java/io/flamingock/store/sql/internal/AuditEntryMapper.java | Adds typed binding/reading of AuditEntry for both audit and journal storage. |
Suppressed comments (1)
core/target-systems/flamingock-sql-externalsystem-api/build.gradle.kts:8
- The SQL external-system API Gradle script still declares an unused
sqlVersionextra and carries over a DynamoDB-onlycompileOnlydependency. Since this module now only exposesSqlExternalSystemand already depends on:core:flamingock-core-commons, these leftovers are misleading and can fail configuration if the extra properties are not defined.
val coreApiVersion: String by extra
val sqlVersion: String by extra
dependencies {
api(project(":core:flamingock-core-commons"))
//General
compileOnly("software.amazon.awssdk:dynamodb-enhanced:2.25.29")
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+34
to
+38
| public SqlAuditRepository(DataSource dataSource, String auditTableName) { | ||
| JournalEventConstants.validateIdentifier(auditTableName, "auditTableName"); | ||
| this.dataSource = dataSource; | ||
| this.auditTableName = auditTableName; | ||
| } |
Comment on lines
+145
to
+149
| public List<AuditEntry> getAuditHistory() { | ||
| List<AuditEntry> entries = new ArrayList<>(); | ||
| try (Connection conn = dataSource.getConnection(); | ||
| Statement stmt = conn.createStatement(); | ||
| ResultSet rs = stmt.executeQuery(dialectHelper.getSelectHistorySqlString(auditTableName))) { |
Comment on lines
+56
to
+60
| public Result writeEntry(AuditEntry auditEntry) { | ||
| Connection conn = null; | ||
| try { | ||
| conn = dataSource.getConnection(); | ||
|
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.