Skip to content

Commit 1f1548d

Browse files
committed
Fix illegal access on PIT creation for frozen index (#73517)
Closes #73514
1 parent 797f66b commit 1f1548d

File tree

4 files changed

+162
-3
lines changed

4 files changed

+162
-3
lines changed

server/src/main/java/org/elasticsearch/index/engine/ReadOnlyEngine.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class ReadOnlyEngine extends Engine {
7676
final boolean lazilyLoadSoftDeletes;
7777

7878
protected volatile TranslogStats translogStats;
79-
protected final String commitId;
79+
private final String commitId;
8080

8181
/**
8282
* Creates a new ReadOnlyEngine. This ctor can also be used to open a read-only engine on top of an already opened
@@ -617,4 +617,8 @@ public String getSearcherId() {
617617
}
618618
};
619619
}
620+
621+
public final String getCommitId() {
622+
return commitId;
623+
}
620624
}

x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ protected void doClose() {
203203

204204
@Override
205205
public String getSearcherId() {
206-
return commitId;
206+
return getCommitId();
207207
}
208208
};
209209
}

x-pack/plugin/searchable-snapshots/qa/rest/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ final File repoDir = file("$buildDir/testclusters/repo")
99

1010
restResources {
1111
restApi {
12-
include 'indices', 'search', 'bulk', 'snapshot', 'nodes', '_common', 'searchable_snapshots', 'cluster'
12+
include 'indices', 'search', 'bulk', 'snapshot', 'nodes', '_common', 'searchable_snapshots', 'cluster', 'open_point_in_time', 'close_point_in_time'
1313
}
1414
}
1515

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
setup:
3+
4+
- do:
5+
indices.create:
6+
index: docs
7+
body:
8+
settings:
9+
number_of_shards: 1
10+
number_of_replicas: 0
11+
12+
- do:
13+
bulk:
14+
body:
15+
- index:
16+
_index: docs
17+
_id: 1
18+
- field: foo
19+
- index:
20+
_index: docs
21+
_id: 2
22+
- field: bar
23+
- index:
24+
_index: docs
25+
_id: 3
26+
- field: baz
27+
28+
- do:
29+
snapshot.create_repository:
30+
repository: repository-fs
31+
body:
32+
type: fs
33+
settings:
34+
location: "repository-fs"
35+
36+
# Remove the snapshot if a previous test failed to delete it.
37+
# Useful for third party tests that runs the test against a real external service.
38+
- do:
39+
snapshot.delete:
40+
repository: repository-fs
41+
snapshot: snapshot
42+
ignore: 404
43+
44+
- do:
45+
snapshot.create:
46+
repository: repository-fs
47+
snapshot: snapshot
48+
wait_for_completion: true
49+
50+
- do:
51+
indices.delete:
52+
index: docs
53+
---
54+
teardown:
55+
56+
- do:
57+
snapshot.delete:
58+
repository: repository-fs
59+
snapshot: snapshot
60+
ignore: 404
61+
62+
- do:
63+
snapshot.delete_repository:
64+
repository: repository-fs
65+
66+
---
67+
"Tests searches vs default-storage index":
68+
- do:
69+
searchable_snapshots.mount:
70+
repository: repository-fs
71+
snapshot: snapshot
72+
wait_for_completion: true
73+
body:
74+
index: docs
75+
renamed_index: docs-default-storage
76+
77+
- match: { snapshot.snapshot: snapshot }
78+
- match: { snapshot.shards.failed: 0 }
79+
- match: { snapshot.shards.successful: 1 }
80+
81+
- do:
82+
search:
83+
index: docs-default-storage
84+
body:
85+
query:
86+
match_all: {}
87+
88+
- match: { hits.total.value: 3 }
89+
90+
- do:
91+
open_point_in_time:
92+
index: docs-default-storage
93+
keep_alive: 5m
94+
- set: {id: point_in_time_id}
95+
96+
- do:
97+
search:
98+
body:
99+
pit:
100+
id: "$point_in_time_id"
101+
keep_alive: 1m
102+
103+
- match: { hits.total.value: 3 }
104+
105+
- do:
106+
close_point_in_time:
107+
body:
108+
id: "$point_in_time_id"
109+
110+
111+
---
112+
"Tests searches vs shared-cache index":
113+
- do:
114+
searchable_snapshots.mount:
115+
repository: repository-fs
116+
snapshot: snapshot
117+
wait_for_completion: true
118+
storage: shared_cache
119+
body:
120+
index: docs
121+
renamed_index: docs-shared-cache
122+
123+
- match: { snapshot.snapshot: snapshot }
124+
- match: { snapshot.shards.failed: 0 }
125+
- match: { snapshot.shards.successful: 1 }
126+
127+
- do:
128+
search:
129+
index: docs-shared-cache
130+
body:
131+
query:
132+
match_all: {}
133+
134+
- match: { hits.total.value: 3 }
135+
136+
- do:
137+
open_point_in_time:
138+
index: docs-shared-cache
139+
keep_alive: 5m
140+
- set: {id: point_in_time_id}
141+
142+
- do:
143+
search:
144+
body:
145+
pit:
146+
id: "$point_in_time_id"
147+
keep_alive: 1m
148+
149+
- match: { hits.total.value: 3 }
150+
151+
- do:
152+
close_point_in_time:
153+
body:
154+
id: "$point_in_time_id"
155+

0 commit comments

Comments
 (0)