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

Store the reason of noop in its document tombstone #30570

Merged
merged 4 commits into from May 15, 2018

Conversation

Projects
None yet
4 participants
@dnhatn
Copy link
Contributor

commented May 14, 2018

Relates #29530

@elasticmachine

This comment has been minimized.

Copy link
Collaborator

commented May 14, 2018

@s1monw
Copy link
Contributor

left a comment

left one question

final ParsedDocument tombstone = engineConfig.getTombstoneDocSupplier().newNoopTombstoneDoc();
final BytesReference reason = BytesReference.bytes(
JsonXContent.contentBuilder().startObject().field(NoOp.REASON_FIELD_NAME, noOp.reason()).endObject());
final ParsedDocument tombstone = engineConfig.getTombstoneDocSupplier().newNoopTombstoneDoc(reason);

This comment has been minimized.

Copy link
@s1monw

s1monw May 14, 2018

Contributor

can't we use a simple stored field? I mean do we have to store json?

@dnhatn

This comment has been minimized.

Copy link
Contributor Author

commented May 14, 2018

@s1monw I tried to keep _source in JSON format as other docs but it was not necessary. I've updated the PR to store the reason in a raw string. Can you please have a look?

@dnhatn dnhatn requested a review from s1monw May 14, 2018

@s1monw

s1monw approved these changes May 14, 2018

@dnhatn

This comment has been minimized.

Copy link
Contributor Author

commented May 14, 2018

@elasticmachine test this please

final SourceToParse sourceToParse = SourceToParse.source(index, type, id, new BytesArray("{}"), XContentType.JSON);
final ParsedDocument parsedDoc = documentParser.parseDocument(sourceToParse, noopTombstoneMetadataFieldMappers).toTombstone();
// Store the reason of a noop as a raw string in the _source field
final BytesRef byteRef = new BytesRef(reason);

This comment has been minimized.

Copy link
@bleskes

bleskes May 15, 2018

Member

I'm doubting about this - should we always make it valid JSON : { "_reason": "bla" } ? I think it might surprising to find non json in the source field.

@bleskes
Copy link
Member

left a comment

I raised a simple issue to discuss.

@dnhatn

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2018

I'm doubting about this - should we always make it valid JSON : { "_reason": "bla" } ? I think it might surprising to find non json in the source field.

@bleskes Originally I made it in JSON but Simon preferred storing it as a raw string. I am fine with both approaches. @simonw WDYT?

@bleskes

This comment has been minimized.

Copy link
Member

commented May 15, 2018

I don't mind much. If Simon prefers a string, I'm good.

@dnhatn

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2018

@elasticmachine test this please

@dnhatn

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2018

Thanks @s1monw and @bleskes

@dnhatn dnhatn merged commit 2a2c23b into elastic:ccr May 15, 2018

3 checks passed

CLA Commit author is a member of Elasticsearch
Details
elasticsearch-ci Build finished.
Details
elasticsearch-ci/packaging-sample Build finished.
Details

@dnhatn dnhatn deleted the dnhatn:store-noop-reason branch May 15, 2018

@dnhatn dnhatn referenced this pull request May 15, 2018

Closed

Use soft-deletes to maintain document history #29530

14 of 14 tasks complete

dnhatn added a commit that referenced this pull request May 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.