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 current translog ID to commit meta before closing #8245

Merged
merged 2 commits into from Oct 28, 2014

Conversation

Projects
None yet
4 participants
@s1monw
Copy link
Contributor

s1monw commented Oct 27, 2014

Today we simply close the IW when we have to open a new one if ie.
we change merge settings. Yet, the API is deprecated and under the hood
it commits the IW. For safety we should add the current translog ID and
use rollback instead to not wait for merges.

@rjernst

This comment has been minimized.

Copy link
Member

rjernst commented Oct 27, 2014

LGTM.

@dakrone

View changes

src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java Outdated
currentIndexWriter().close(false);
{ // commit and close the current writer - we write the current tanslog ID just in case
final long translogId = translog.currentId();
indexWriter.setCommitData(MapBuilder.<String, String>newMapBuilder().put(Translog.TRANSLOG_ID_KEY, Long.toString(translogId)).map());

This comment has been minimized.

Copy link
@dakrone

dakrone Oct 27, 2014

Member

Asking for my own information here, but would it be more efficient to use new HashMap<String, String>(1) because we always know the capacity for the HashMap? The default constructor has an initialCapacity of 16, does it save much to manually lower it?

This comment has been minimized.

Copy link
@s1monw

s1monw Oct 28, 2014

Author Contributor

almost certainly - I just copy pasted this feel free to cut over the other places ;)

s1monw added some commits Oct 27, 2014

[ENGINE] Add current translog ID to commit meta before closing
Today we simply close the IW when we have to open a new one if ie.
we change merge settings. Yet, the API is deprecated and under the hood
it commits the IW. For safety we should add the current translog ID and
use rollback instead to not wait for merges.

@s1monw s1monw force-pushed the s1monw:remove_deprecated_close branch to 31db8cc Oct 28, 2014

@s1monw

This comment has been minimized.

Copy link
Contributor Author

s1monw commented Oct 28, 2014

@dakrone I pushed another commit that fixes the map builder too

@dakrone

This comment has been minimized.

Copy link
Member

dakrone commented Oct 28, 2014

LGTM

@s1monw s1monw merged commit 31db8cc into elastic:master Oct 28, 2014

@s1monw s1monw deleted the s1monw:remove_deprecated_close branch Oct 28, 2014

@s1monw s1monw removed the review label Oct 28, 2014

@clintongormley clintongormley changed the title [ENGINE] Add current translog ID to commit meta before closing Internal: Add current translog ID to commit meta before closing Nov 3, 2014

@clintongormley clintongormley changed the title Internal: Add current translog ID to commit meta before closing Add current translog ID to commit meta before closing Jun 7, 2015

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.