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

Optimize read write lock constructs during translog upload to remote store #10013

Closed
ashking94 opened this issue Sep 13, 2023 · 2 comments · Fixed by #9636
Closed

Optimize read write lock constructs during translog upload to remote store #10013

ashking94 opened this issue Sep 13, 2023 · 2 comments · Fixed by #9636
Labels
enhancement Enhancement or improvement to existing feature or request Storage:Durability Issues and PRs related to the durability framework Storage Issues and PRs relating to data and metadata storage v2.11.0 Issues and PRs related to version 2.11.0

Comments

@ashking94
Copy link
Member

ashking94 commented Sep 13, 2023

Is your feature request related to a problem? Please describe.
While performing OpenSearch Benchmark runs, discovered a potential optimisation that obstructs the add to translog when the translog upload to remote store is ongoing.

Translog add :

public Location add(final Operation operation) throws IOException {
final ReleasableBytesStreamOutput out = new ReleasableBytesStreamOutput(bigArrays);
try {
final long start = out.position();
out.skip(Integer.BYTES);
writeOperationNoSize(new BufferedChecksumStreamOutput(out), operation);
final long end = out.position();
final int operationSize = (int) (end - Integer.BYTES - start);
out.seek(start);
out.writeInt(operationSize);
out.seek(end);
final BytesReference bytes = out.bytes();
try (ReleasableLock ignored = readLock.acquire()) {
ensureOpen();
if (operation.primaryTerm() > current.getPrimaryTerm()) {
assert false : "Operation term is newer than the current term; "
+ "current term["
+ current.getPrimaryTerm()
+ "], operation term["
+ operation
+ "]";
throw new IllegalArgumentException(
"Operation term is newer than the current term; "
+ "current term["
+ current.getPrimaryTerm()
+ "], operation term["
+ operation
+ "]"
);
}
return current.add(bytes, operation.seqNo());
}
} catch (final AlreadyClosedException | IOException ex) {
closeOnTragicEvent(ex);
throw ex;
} catch (final Exception ex) {
closeOnTragicEvent(ex);
throw new TranslogException(shardId, "Failed to write operation [" + operation + "]", ex);
} finally {
Releasables.close(out);
}
}

RemoteFsTranslog prepareForUpload :

public boolean ensureSynced(Location location) throws IOException {
try (ReleasableLock ignored = writeLock.acquire()) {
assert location.generation <= current.getGeneration();
if (location.generation == current.getGeneration()) {
ensureOpen();
return prepareAndUpload(primaryTermSupplier.getAsLong(), location.generation);
}
} catch (final Exception ex) {
closeOnTragicEvent(ex);
throw ex;
}
return false;
}

@ashking94 ashking94 added enhancement Enhancement or improvement to existing feature or request untriaged labels Sep 13, 2023
@ashking94 ashking94 added Storage:Durability Issues and PRs related to the durability framework Storage Issues and PRs relating to data and metadata storage v2.11.0 Issues and PRs related to version 2.11.0 and removed untriaged labels Sep 13, 2023
@msfroh
Copy link
Collaborator

msfroh commented Sep 14, 2023

While performing OpenSearch Benchmark runs, discovered a potential optimisation that obstructs the add to translog when the translog upload to remote store is ongoing.

Can you clarify what the optimization is?

@ashking94
Copy link
Member Author

While performing OpenSearch Benchmark runs, discovered a potential optimisation that obstructs the add to translog when the translog upload to remote store is ongoing.

Can you clarify what the optimization is?

Currently the translog upload to remote store is happening within the write lock. I am trying to break it up and move the upload within read lock. #9636 is an attempt to do the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request Storage:Durability Issues and PRs related to the durability framework Storage Issues and PRs relating to data and metadata storage v2.11.0 Issues and PRs related to version 2.11.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants