Skip to content

Commit

Permalink
Fix illegal access on PIT creation for frozen index (#73517)
Browse files Browse the repository at this point in the history
Closes #73514
  • Loading branch information
DaveCTurner authored May 28, 2021
1 parent 0560caa commit 2b521e3
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class ReadOnlyEngine extends Engine {
final boolean lazilyLoadSoftDeletes;

protected volatile TranslogStats translogStats;
protected final String commitId;
private final String commitId;

/**
* Creates a new ReadOnlyEngine. This ctor can also be used to open a read-only engine on top of an already opened
Expand Down Expand Up @@ -583,4 +583,8 @@ public String getSearcherId() {
}
};
}

public final String getCommitId() {
return commitId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected void doClose() {

@Override
public String getSearcherId() {
return commitId;
return getCommitId();
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugin/searchable-snapshots/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final File repoDir = file("$buildDir/testclusters/repo")

restResources {
restApi {
include 'indices', 'search', 'bulk', 'snapshot', 'nodes', '_common', 'searchable_snapshots', 'cluster'
include 'indices', 'search', 'bulk', 'snapshot', 'nodes', '_common', 'searchable_snapshots', 'cluster', 'open_point_in_time', 'close_point_in_time'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
setup:

- do:
indices.create:
index: docs
body:
settings:
number_of_shards: 1
number_of_replicas: 0

- do:
bulk:
body:
- index:
_index: docs
_id: 1
- field: foo
- index:
_index: docs
_id: 2
- field: bar
- index:
_index: docs
_id: 3
- field: baz

- do:
snapshot.create_repository:
repository: repository-fs
body:
type: fs
settings:
location: "repository-fs"

# Remove the snapshot if a previous test failed to delete it.
# Useful for third party tests that runs the test against a real external service.
- do:
snapshot.delete:
repository: repository-fs
snapshot: snapshot
ignore: 404

- do:
snapshot.create:
repository: repository-fs
snapshot: snapshot
wait_for_completion: true

- do:
indices.delete:
index: docs
---
teardown:

- do:
snapshot.delete:
repository: repository-fs
snapshot: snapshot
ignore: 404

- do:
snapshot.delete_repository:
repository: repository-fs

---
"Tests searches vs default-storage index":
- do:
searchable_snapshots.mount:
repository: repository-fs
snapshot: snapshot
wait_for_completion: true
body:
index: docs
renamed_index: docs-default-storage

- match: { snapshot.snapshot: snapshot }
- match: { snapshot.shards.failed: 0 }
- match: { snapshot.shards.successful: 1 }

- do:
search:
index: docs-default-storage
body:
query:
match_all: {}

- match: { hits.total.value: 3 }

- do:
open_point_in_time:
index: docs-default-storage
keep_alive: 5m
- set: {id: point_in_time_id}

- do:
search:
body:
pit:
id: "$point_in_time_id"
keep_alive: 1m

- match: { hits.total.value: 3 }

- do:
close_point_in_time:
body:
id: "$point_in_time_id"


---
"Tests searches vs shared-cache index":
- do:
searchable_snapshots.mount:
repository: repository-fs
snapshot: snapshot
wait_for_completion: true
storage: shared_cache
body:
index: docs
renamed_index: docs-shared-cache

- match: { snapshot.snapshot: snapshot }
- match: { snapshot.shards.failed: 0 }
- match: { snapshot.shards.successful: 1 }

- do:
search:
index: docs-shared-cache
body:
query:
match_all: {}

- match: { hits.total.value: 3 }

- do:
open_point_in_time:
index: docs-shared-cache
keep_alive: 5m
- set: {id: point_in_time_id}

- do:
search:
body:
pit:
id: "$point_in_time_id"
keep_alive: 1m

- match: { hits.total.value: 3 }

- do:
close_point_in_time:
body:
id: "$point_in_time_id"

0 comments on commit 2b521e3

Please sign in to comment.