You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JAMES-4231 PostgreSQL: Implement PostgresBlobIdUpdater for S3 compaction support - #3216
Dependency: This PR is branched off master and depends on #3193 for the BlobIdUpdater SPI (server/blob/blob-api). CI compile checks will succeed once #3193 is merged to master.
Proposed Changes
This PR provides PostgreSQL support for S3 Object Compaction by implementing PostgresBlobIdUpdater and binding it in PostgresMailboxModule.
Context & Motivation
In #3193, BlobIdUpdater was introduced to decouple blob storage from database reference updating during S3 object compaction. While Cassandra was implemented initially in #3193 (CassandraBlobIdUpdater), PostgreSQL deployments also require a BlobIdUpdater implementation to support compaction when using PostgreSQL metadata with S3 blob storage.
This change brings PostgreSQL to feature parity:
PostgresBlobIdUpdater:
Implements BlobIdUpdater and BlobIdUpdater.Factory.
Reference Scanning: Scans message (body_blob_id) and attachment (blob_id) tables using keyset paginated queries via PostgresExecutor.executeRowsPaginated.
Generation Tracking: Observes all live references and records candidate IDs matching the target generation condition.
Atomic Batched Updates: Replaces references in batches of 500 targeting primary keys (message_id UUID and attachment.id) with conditional guards (body_blob_id = oldId / blob_id = oldId).
PostgresMailboxModule:
Binds BlobIdUpdater.Factory to PostgresBlobIdUpdater.Factory in singleton scope.
Tests:
PostgresBlobIdUpdaterTest runs against PostgreSQL Testcontainers verifying:
Message body blob ID replacement
Attachment blob ID replacement
Generation predicate filtering
Idempotency when replacing non-existent references
08:24:41,160 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.14.0:compile (default-compile) on project apache-james-mailbox-postgres: Compilation failure: Compilation failure:
08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[38,33] cannot find symbol
08:24:41,161 [ERROR] symbol: class BlobIdUpdater
08:24:41,161 [ERROR] location: package org.apache.james.blob.api
08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[47,47] cannot find symbol
08:24:41,161 [ERROR] symbol: class BlobIdUpdater
08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[48,57] package BlobIdUpdater does not exist
08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[61,21] cannot find symbol
08:24:41,161 [ERROR] symbol: class BlobIdUpdater
08:24:41,161 [ERROR] location: class org.apache.james.mailbox.postgres.mail.PostgresBlobIdUpdater.Factory
08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[60,9] method does not override or implement a method from a supertype
08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[121,5] method does not override or implement a method from a supertype
08:24:41,161 [ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execut
08:24:41,160 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.14.0:compile (default-compile) on project apache-james-mailbox-postgres: Compilation failure: Compilation failure: 08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[38,33] cannot find symbol 08:24:41,161 [ERROR] symbol: class BlobIdUpdater 08:24:41,161 [ERROR] location: package org.apache.james.blob.api 08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[47,47] cannot find symbol 08:24:41,161 [ERROR] symbol: class BlobIdUpdater 08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[48,57] package BlobIdUpdater does not exist 08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[61,21] cannot find symbol 08:24:41,161 [ERROR] symbol: class BlobIdUpdater 08:24:41,161 [ERROR] location: class org.apache.james.mailbox.postgres.mail.PostgresBlobIdUpdater.Factory 08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[60,9] method does not override or implement a method from a supertype 08:24:41,161 [ERROR] /home/jenkins/jenkins-agent/workspace/james_ApacheJames_PR-3216/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresBlobIdUpdater.java:[121,5] method does not override or implement a method from a supertype 08:24:41,161 [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execut
Yes there is a dependency issue
Dependency: This PR is branched off master and depends on #3193 for the BlobIdUpdater SPI (server/blob/blob-api). CI compile checks will succeed once #3193 is merged to master.
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
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.
JIRA: https://issues.apache.org/jira/browse/JAMES-4231
Note
Dependency: This PR is branched off
masterand depends on #3193 for theBlobIdUpdaterSPI (server/blob/blob-api). CI compile checks will succeed once #3193 is merged to master.Proposed Changes
This PR provides PostgreSQL support for S3 Object Compaction by implementing
PostgresBlobIdUpdaterand binding it inPostgresMailboxModule.Context & Motivation
In #3193,
BlobIdUpdaterwas introduced to decouple blob storage from database reference updating during S3 object compaction. While Cassandra was implemented initially in #3193 (CassandraBlobIdUpdater), PostgreSQL deployments also require aBlobIdUpdaterimplementation to support compaction when using PostgreSQL metadata with S3 blob storage.This change brings PostgreSQL to feature parity:
PostgresBlobIdUpdater:BlobIdUpdaterandBlobIdUpdater.Factory.message(body_blob_id) andattachment(blob_id) tables using keyset paginated queries viaPostgresExecutor.executeRowsPaginated.message_idUUID andattachment.id) with conditional guards (body_blob_id = oldId/blob_id = oldId).PostgresMailboxModule:BlobIdUpdater.FactorytoPostgresBlobIdUpdater.Factoryin singleton scope.PostgresBlobIdUpdaterTestruns against PostgreSQL Testcontainers verifying: