Skip to content

Conversation

Tim-Brooks
Copy link
Contributor

This is related to #35975. It implements a file based restore in the
CcrRepository. The restore transfers files from the leader cluster
to the follower cluster. It does not implement any advanced resiliency
features at the moment. Any request failure will end the restore.

@Tim-Brooks Tim-Brooks added >non-issue v7.0.0 :Distributed Indexing/CCR Issues around the Cross Cluster State Replication features v6.7.0 labels Jan 4, 2019
@Tim-Brooks Tim-Brooks requested a review from bleskes January 4, 2019 00:44
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@Tim-Brooks Tim-Brooks requested a review from ywelsch January 4, 2019 00:44
Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tbrooks8. My main concern is with the large amount of code copied from BlobStoreRepository, which will be difficult to maintain. Can you investigate ways of reusing code?

@@ -133,6 +133,17 @@ public synchronized void closeSession(String sessionUUID) {
IOUtils.closeWhileHandlingException(restore);
}

// TODO: The Engine.IndexCommitRef might be closed by a different thread while it is in use. We need to
// look into the implications of this.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the RecoveryTarget object, we could use some ref-counting here (see AbstractRefCounted)

Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some generic comments

private final ThreadPool threadPool;

@Inject
public TransportGetCcrRestoreFileChunkAction(ThreadPool threadPool, TransportService transportService, ActionFilters actionFilters,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a ctor to HandledTransportAction that allows you to specify the threadpool instead of forking internally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to do this in a follow up? There are some tricky components to this for a generic solution (such as stashing headers to the new thread, etc). And questions about whether we want to do the action filter on a new thread.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I follow. Why is this action different from any other?

@Tim-Brooks Tim-Brooks requested review from ywelsch and s1monw January 11, 2019 02:04
Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some more comments. We are getting there! thanks for the iterations

// Should not access this method while holding global lock as that might block the cluster state
// update thread on IO if it calls afterIndexShardClosed
assert Thread.holdsLock(CcrRestoreSourceService.this) == false : "Should not hold CcrRestoreSourceService lock";
if (cachedInput != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the cachedInput I think what we should do here is to have a Map<String,IndexInput> and close it after a read if (in.getFilePointer() == in.length()) Also I wonder if the sync on this method is necessary or if we rather should not synchronized but instead have a KeyedLock<String>. This way we can implement this:

try (Releasable lock = keyedLock.tryAcquire(fileName)) {
  if (lock == null) {
    throw new IllegalStateException("can't read from the same file on the same session concurrently");
  }
  // do the read
}

this would give us the right guarantees rather than hiding bugs.


int bytesRequested = (int) Math.min(remainingBytes, len);
String fileName = fileToRecover.name();
GetCcrRestoreFileChunkRequest request = new GetCcrRestoreFileChunkRequest(node, sessionUUID, fileName, bytesRequested);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should get back the offset from the remote call and then assert that is matches with the offset we have stored in pos This would add another level of safety.

@Tim-Brooks
Copy link
Contributor Author

I implemented @s1monw changes.

@Tim-Brooks Tim-Brooks requested a review from s1monw January 12, 2019 02:08
Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM left 1 comment

Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good. I've left some nits and one minor comment about the offset field.


@Override
public DiscoveryNode getPreferredTargetNode() {
return node;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe assert here that node is not-null?


public static class GetCcrRestoreFileChunkResponse extends ActionResponse {

private final long offset;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

offset is typically the beginning of the range that is sent. Having it different here is a potential source for confusion in the future. I see two options: 1) Name it differently or 2) make it the offset that represents the beginning of the range that is sent. I'm strongly favoring 2), which is a small change to make, and provides the same validation on the receiver.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with number 2.

Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. You'll need to merge latest master here to get CI passing.

@Tim-Brooks
Copy link
Contributor Author

run gradle build tests 1

@Tim-Brooks Tim-Brooks merged commit 5c68338 into elastic:master Jan 14, 2019
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 15, 2019
* master: (28 commits)
  Introduce retention lease serialization (elastic#37447)
  Update Delete Watch to allow unknown fields (elastic#37435)
  Make finalize step of recovery source non-blocking (elastic#37388)
  Update the default for include_type_name to false. (elastic#37285)
  Security: remove SSL settings fallback (elastic#36846)
  Adding mapping for hostname field (elastic#37288)
  Relax assertSameDocIdsOnShards assertion
  Reduce recovery time with compress or secure transport (elastic#36981)
  Implement ccr file restore (elastic#37130)
  Fix Eclipse specific compilation issue (elastic#37419)
  Performance fix. Reduce deprecation calls for the same bulk request (elastic#37415)
  [ML] Use String rep of Version in map for serialisation (elastic#37416)
  Cleanup Deadcode in Rest Tests (elastic#37418)
  Mute IndexShardRetentionLeaseTests.testCommit elastic#37420
  unmuted test
  Remove unused index store in directory service
  Improve CloseWhileRelocatingShardsIT (elastic#37348)
  Fix ClusterBlock serialization and Close Index API logic after backport to 6.x (elastic#37360)
  Update the scroll example in the docs (elastic#37394)
  Update analysis.asciidoc (elastic#37404)
  ...
Tim-Brooks added a commit to Tim-Brooks/elasticsearch that referenced this pull request Jan 21, 2019
This is related to elastic#35975. It implements a file based restore in the
CcrRepository. The restore transfers files from the leader cluster
to the follower cluster. It does not implement any advanced resiliency
features at the moment. Any request failure will end the restore.
Tim-Brooks added a commit that referenced this pull request Jan 21, 2019
This is related to #35975. It implements a file based restore in the
CcrRepository. The restore transfers files from the leader cluster
to the follower cluster. It does not implement any advanced resiliency
features at the moment. Any request failure will end the restore.
ywelsch added a commit that referenced this pull request Mar 20, 2019
A recent refactoring (#37130) where imports got mixed up (changing Lucene's
IndexNotFoundException to Elasticsearch's IndexNotFoundException) led to many warnings being
logged in case of restoring a fresh snapshot.
ywelsch added a commit that referenced this pull request Mar 20, 2019
A recent refactoring (#37130) where imports got mixed up (changing Lucene's
IndexNotFoundException to Elasticsearch's IndexNotFoundException) led to many warnings being
logged in case of restoring a fresh snapshot.
ywelsch added a commit that referenced this pull request Mar 20, 2019
A recent refactoring (#37130) where imports got mixed up (changing Lucene's
IndexNotFoundException to Elasticsearch's IndexNotFoundException) led to many warnings being
logged in case of restoring a fresh snapshot.
ywelsch added a commit that referenced this pull request Mar 20, 2019
A recent refactoring (#37130) where imports got mixed up (changing Lucene's
IndexNotFoundException to Elasticsearch's IndexNotFoundException) led to many warnings being
logged in case of restoring a fresh snapshot.
@Tim-Brooks Tim-Brooks deleted the ccr_file_recovery branch December 18, 2019 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/CCR Issues around the Cross Cluster State Replication features >non-issue v6.7.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants