Repository navigation
Introduce BlobMailRepositoryV2 (skeleton) - #3213
prosgarz35 wants to merge 8 commits into
Conversation
| } | ||
|
|
||
| @Test | ||
| void removeAllShouldBeIsolatedAcrossRepositories() throws Exception { |
There was a problem hiding this comment.
Those tests are generic and should be moved to the contract IMO
There was a problem hiding this comment.
Do we have a test
var/mail/error do not list var/mail/error-backup content ?
There was a problem hiding this comment.
With the dedup/GC module, asString() becomes family_generation_ (or family/generation/ for MinIO). The ownership check would then reject every mail, and those mails would become invisible. It's not a regression: the old belongsToMailRepository used the same startsWith and was already broken there, and the new listBlobs(bucket, prefix) behaves the same way
I'd favour finding something agnostic to the blobId format. It's an important architectural property that let's us build cool feature like #3193
Performance. size and list now read and decode every metadata blob (N GETs), where before they only listed ids. That doesn't break anything, but it's noticeably heavier on big error repositories.
I do not know if this is structurally needed ?
|
Can we also please create a JIRA for the underlying bug please ? |
chibenwa
left a comment
There was a problem hiding this comment.
Also storage format changed.
I'd be cautious with retro compatibility and explicitly test this: write some blobs by hand according to how they were previously stored and ensure that repository content is still redable with new code.
if we can avoid a breaking change...
we can avoid it for now but format needed to change in future i cant remember correctly but there problem with parsing json or something so no way in current format fully fix this problems |
|
You don't get it - if we break retro compatibility, we need to come up with a migration trategy which I'd like to avoid. Also @jeantil you might want to review this... |
yeah i get it for now we must have backward fully compability |
tomorrow :) 22.30 now |
ce65ce5 to
d7cd227
Compare
| oldMimeId.foreach(mimeId => | ||
| SMono.fromPublisher(mimeMessageStore.delete(mimeId)) | ||
| .retryWhen(Retry.backoff(2, Duration.ofMillis(50))) | ||
| .doOnError(e => LOGGER.warn("Failed to delete superseded MIME blobs {} and {} for mail {} in {}", | ||
| mimeId.getHeaderBlobId.asString(), mimeId.getBodyBlobId.asString(), mc.getName, url.asString(), e)) | ||
| .onErrorResume(_ => SMono.empty) | ||
| .block() | ||
| ) |
There was a problem hiding this comment.
We should have IMO a plan for dropping those exta reads.
My proposition is to:
- Leave BlobMailRepository -> untouched but marked as deprecated and to be removed after 3.10.0 release
- Have a BlobMailRepositoryV2 which do NOT handle retrocompatibility and adopt whatever format is most suited
- Write a upgrade instruction saying that BlobMailRepository will be dropped next release. That users can configure both
BlobMailRepositoryandBlobMailRepositoryV2playing mailrepositorystore.xml config and move messages via webadmin. They shall do that prior 3.11.0.
Exact steps would be:
- A. add blobv2:// backed by BlobMailRepositoryV2 in mailrepositorystore.xml
- A. and Update mailet container to use blobv2://
- A. and reboot james
- B. move things from blob:// to blobv2:// cf webadmin API
- C: Set blob:// to be backed by BlobMailRepositoryV2
- C: and Update mailet container to use blob://
- C: and remove blobv2:// section
- C: and reboot
I believe it provides a clear discontinuation plan with limited compexity on our hand and limits retro compatibility concerns: our hands are free to make optimal choices.
Opinion ?
There was a problem hiding this comment.
I surely like idea, but not sure i can make so complicated task, i try it ! So really that needed? We have something already like v2 ?
https://james.staged.apache.org/james-project/3.10.0/servers/distributed/operate/webadmin.html#_moving_mails_from_a_mail_repository_to_another its good feature!
There was a problem hiding this comment.
https://james.staged.apache.org/james-project/3.10.0/servers/distributed/operate/webadmin.html#_moving_mails_from_a_mail_repository_to_another its good feature!
We try to sometime have good ideas ^^
There was a problem hiding this comment.
Cut it in small parts:
- 1 PR for contract changes, @disabled for BlobMailRepository
- 1 PR for BlobMailRepositoryV2 alone
- 1 PR for deprecation and upgrade procedure.
Smaller chunks makes things generally more manageable.
|
this PR going be V2 blueprint |
|
What you think about it Dear @chibenwa ? |
| @Test | ||
| @Disabled("This repository removes blobs rather than mails: it can not tell which of them back a mail") | ||
| @Override | ||
| public void removeAllShouldReportTheRemovedMails() { | ||
| } |
There was a problem hiding this comment.
That's a pity can't we manage to solve this one in v2
chibenwa
left a comment
There was a problem hiding this comment.
BlobMailRepositoryV2BlobReferenceSource must also list metadata blobs
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| blobIdFactory = new PlainBlobId.Factory(); |
There was a problem hiding this comment.
We need a test with GenerationAwareBlobId.Factory
| .onErrorResume(e => { | ||
| LOGGER.warn("Failed listing referenced MIME parts for a BlobMailRepositoryV2 instance", e) | ||
| Flux.empty() | ||
| })) |
There was a problem hiding this comment.
| .onErrorResume(e => { | |
| LOGGER.warn("Failed listing referenced MIME parts for a BlobMailRepositoryV2 instance", e) | |
| Flux.empty() | |
| })) |
Swallowing failures result in data loss. We MUST propagate.
|
@quantranhong1999 can i ask you do this too? Thanks :3 |
done ^^ |
|
org.apache.james.mailrepository.blob.GenerationAwareBlobMailRepositoryV2Test.storingAndRemovingMessagesConcurrentlyShouldLeadToConsistentResult()[6] En échec depuis 3 builds (Depuis En échec#14 ) Résultats des tests (26 échecs / ±0) Related I presume... |
chibenwa
left a comment
There was a problem hiding this comment.
Thanks for iterating. CI is green now.
A few points before this can serve as the V2 blueprint:
- The description says listing uses listBlobs(bucket, prefix), but the code still lists the whole default bucket and filters in memory. size/list/removeAll/GC each trigger a full bucket scan (shared with all mailbox blobs), once per repository for the GC. Can we at least use prefixes ?
- contains(path + "/") breaks isolation: mails of foo/var/mail/error are listed, counted and removed by removeAll in var/mail/error. It also still depends on the blob id format. Please add isolation tests (error vs error-backup, nested/suffix paths).
- With GenerationAwareBlobId, re-storing the same key after a generation change creates a second metadata blob, leading to duplicate listing and partial removal. Please test with a ticking clock.
- Leaving superseded MIME blobs to the GC only works with deduplication. The factory builds passthrough stores, where overwrites and failed removes leak blobs forever.
- retrieve swallows errors (onErrorReturn(None)) and hides mails. Please propagate.
- version is never checked on read, and attributes are still JSON-in-JSON. If the format is free, let's fix that now.
- Can removeAllShouldReportTheRemovedMails be enabled for V2?
Maybe we can:
- Use a dedicated bucket
- Rely on S3BlobStoreDAO and forget about MimeMessageStore
Would make this:
- Independant from the GC
- Allow to be duplicating
|
Hello @prosgarz35 Can I ask you for the state of this work? Do you plan to further work on this topic? Best regards, Benoit |
I have to admit, hearing my feedback framed as 'special needs' caught me a bit off guard and felt a bit discouraging. But looking past that, maybe it's worth following his suggestion, even if my only 'special need' was just wanting more than a single option for a non-distributed system. |
|
Hello @prosgarz35 It took me a while to understand the context. I'm pretty sure "special needs" was meant as "specific requirements": we are all writing in a non-native language here, and that expression carries a connotation in English its author very likely did not intend - nor did I before I checked the dictionnary. Suggesting a fork is a common path in open source to prove a backend can be maintained over time, not a dismissal of your use case. That discussion was about adding new storage backends upstream. Best regards, Benoit |
Thank you, Benoit, for stepping in and clarifying the context. I’d certainly like to believe he meant no harm with the original comment, and I'm glad to move forward from this. |
|
Thanks for sharing. Health first. Take time needed for recovery, if needed we would take care of the follow ups and do not hesitate to ask for help. Best regards |
Context
This PR supersedes the earlier repository-isolation approach on this branch.
Per review discussion (@chibenwa), instead of patching
BlobMailRepositoryin place — which raised retro-compatibility and blob-id-format concerns — we
introduce a new, self-contained
BlobMailRepositoryV2behind a dedicatedblobv2://protocol. This keeps the change small and reviewable, and leavesBlobMailRepository(V1) completely untouched.This is intentionally a skeleton: it establishes the V2 type, its own
storage format, factory, GC integration and Guice wiring. Follow-up concerns
(deprecating V1,
@Disabledcontract adjustments, upgrade/migrationinstructions) are deliberately left out and will be handled in separate PRs,
as agreed.
What this PR does
BlobMailRepositoryV2— aMailRepositorybacked by the blob store,fully independent from V1. Unlike V1,
storedoes not read-then-delete apossibly-superseded MIME blob on overwrite; it always writes a fresh
mail + metadata pair. Orphaned MIME blobs from superseded writes are left to
the blob-store garbage collector.
MailMetadataV2— V2's own on-wire metadata schema (with its ownHeaderV2). It carries a leadingversiondiscriminator(
CURRENT_VERSION = 2) stamped on every write, so the format can evolvefreely without any retro-compatibility constraint against V1.
MailRepositoryBlobIdFactoryV2— V2's own url-prefixed blob-id factory.BlobMailRepositoryV2Factory— mirrorsBlobMailRepositoryFactory,wired to the
blobv2://protocol.BlobMailRepositoryV2BlobReferenceSource— reports the MIME partsreferenced by every
BlobMailRepositoryV2instance to the blob-store GC, solive MIME blobs are not reclaimed as orphans. Registered via a
Multibinder<BlobReferenceSource>.BlobstoreMailRepositoryModule— registers theblobv2://protocol(
@ProvidesIntoSetfactory) and the reference source.Design notes
with
BlobMailRepository. Dropping V1 in a later release is a pure filedeletion with zero impact on V2.
prefix via
listBlobs(bucket, prefix)(with a trailing/), so operationson one repository never touch blobs of another repository sharing the same
bucket.
mailMetadataV2(distinct from V1'smailMetadata).Testing
BlobMailRepositoryV2Testexercises the sharedMailRepositoryContract(same coverage as
BlobMailRepositoryTest).mvn test-compile checkstyle:check(0 Checkstyleviolations) and a full reactor build up to the Guice mailrepository module.
Out of scope (follow-up PRs)
BlobMailRepository/ contract@Disabledadjustments.blob://→blobv2://via webadmin).