Skip to content

Commit 1415e2b

Browse files
committed
Merge branch 'master' into byte-size-value-setting-limit-error-message
* master: Remove silent batch mode from install plugin (elastic#29359) Align cat thread pool info to thread pool config (elastic#29195) Track Lucene operations in engine explicitly (elastic#29357)
2 parents 751f92e + 5cdd831 commit 1415e2b

File tree

9 files changed

+108
-56
lines changed

9 files changed

+108
-56
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ class ClusterFormationTasks {
494494
* the short name requiring the path to already exist.
495495
*/
496496
final Object esPluginUtil = "${-> node.binPath().resolve('elasticsearch-plugin').toString()}"
497-
final Object[] args = [esPluginUtil, 'install', file]
497+
final Object[] args = [esPluginUtil, 'install', '--batch', file]
498498
return configureExecTask(name, project, setup, node, args)
499499
}
500500

distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ protected void printAdditionalHelp(Terminal terminal) {
208208
@Override
209209
protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception {
210210
String pluginId = arguments.value(options);
211-
boolean isBatch = options.has(batchOption) || System.console() == null;
211+
final boolean isBatch = options.has(batchOption);
212212
execute(terminal, pluginId, isBatch, env);
213213
}
214214

docs/reference/cat/thread_pool.asciidoc

+4-3
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,15 @@ in the table below.
113113
|Field Name |Alias |Description
114114
|`type` |`t` |The current (*) type of thread pool (`fixed` or `scaling`)
115115
|`active` |`a` |The number of active threads in the current thread pool
116-
|`size` |`s` |The number of threads in the current thread pool
116+
|`pool_size` |`psz` |The number of threads in the current thread pool
117117
|`queue` |`q` |The number of tasks in the queue for the current thread pool
118118
|`queue_size` |`qs` |The maximum number of tasks permitted in the queue for the current thread pool
119119
|`rejected` |`r` |The number of tasks rejected by the thread pool executor
120120
|`largest` |`l` |The highest number of active threads in the current thread pool
121121
|`completed` |`c` |The number of tasks completed by the thread pool executor
122-
|`min` |`mi` |The configured minimum number of active threads allowed in the current thread pool
123-
|`max` |`ma` |The configured maximum number of active threads allowed in the current thread pool
122+
|`core` |`cr` |The configured core number of active threads allowed in the current thread pool
123+
|`max` |`mx` |The configured maximum number of active threads allowed in the current thread pool
124+
|`size` |`sz` |The configured fixed number of active threads allowed in the current thread pool
124125
|`keep_alive` |`k` |The configured keep alive time for threads
125126
|=======================================================================
126127

qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ fi
416416

417417
@test "[$GROUP] install a sample plugin with different logging modes and check output" {
418418
local relativePath=${1:-$(readlink -m custom-settings-*.zip)}
419-
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/elasticsearch-plugin" install "file://$relativePath" > /tmp/plugin-cli-output
419+
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/elasticsearch-plugin" install --batch "file://$relativePath" > /tmp/plugin-cli-output
420420
# exclude progress line
421421
local loglines=$(cat /tmp/plugin-cli-output | grep -v "^[[:cntrl:]]" | wc -l)
422422
[ "$loglines" -eq "2" ] || {
@@ -427,7 +427,7 @@ fi
427427
remove_plugin_example
428428

429429
local relativePath=${1:-$(readlink -m custom-settings-*.zip)}
430-
sudo -E -u $ESPLUGIN_COMMAND_USER ES_JAVA_OPTS="-Des.logger.level=DEBUG" "$ESHOME/bin/elasticsearch-plugin" install "file://$relativePath" > /tmp/plugin-cli-output
430+
sudo -E -u $ESPLUGIN_COMMAND_USER ES_JAVA_OPTS="-Des.logger.level=DEBUG" "$ESHOME/bin/elasticsearch-plugin" install --batch "file://$relativePath" > /tmp/plugin-cli-output
431431
local loglines=$(cat /tmp/plugin-cli-output | grep -v "^[[:cntrl:]]" | wc -l)
432432
[ "$loglines" -gt "2" ] || {
433433
echo "Expected more than 2 lines excluding progress bar but the output had $loglines lines and was:"

qa/vagrant/src/test/resources/packaging/utils/plugins.bash

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ install_plugin() {
4747
fi
4848

4949
if [ -z "$umask" ]; then
50-
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/elasticsearch-plugin" install -batch "file://$path"
50+
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/elasticsearch-plugin" install --batch "file://$path"
5151
else
52-
sudo -E -u $ESPLUGIN_COMMAND_USER bash -c "umask $umask && \"$ESHOME/bin/elasticsearch-plugin\" install -batch \"file://$path\""
52+
sudo -E -u $ESPLUGIN_COMMAND_USER bash -c "umask $umask && \"$ESHOME/bin/elasticsearch-plugin\" install --batch \"file://$path\""
5353
fi
5454

5555
#check we did not accidentially create a log file as root as /usr/share/elasticsearch

rest-api-spec/src/main/resources/rest-api-spec/test/cat.thread_pool/10_basic.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
"Test cat thread_pool output":
33

4+
- skip:
5+
version: " - 6.99.99"
6+
reason: this API was changed in a backwards-incompatible fashion in 7.0.0 so we need to skip in a mixed cluster
7+
48
- do:
59
cat.thread_pool: {}
610

@@ -46,25 +50,25 @@
4650
- do:
4751
cat.thread_pool:
4852
thread_pool_patterns: bulk
49-
h: id,name,type,active,size,queue,queue_size,rejected,largest,completed,min,max,keep_alive
53+
h: id,name,type,active,pool_size,queue,queue_size,rejected,largest,completed,core,max,size,keep_alive
5054
v: true
5155

5256
- match:
5357
$body: |
54-
/^ id \s+ name \s+ type \s+ active \s+ size \s+ queue \s+ queue_size \s+ rejected \s+ largest \s+ completed \s+ min \s+ max \s+ keep_alive \n
55-
(\S+ \s+ bulk \s+ fixed \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \S* \n)+ $/
58+
/^ id \s+ name \s+ type \s+ active \s+ pool_size \s+ queue \s+ queue_size \s+ rejected \s+ largest \s+ completed \s+ core \s+ max \s+ size \s+ keep_alive \n
59+
(\S+ \s+ bulk \s+ fixed \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \d* \s+ \S* \n)+ $/
5660
5761
- do:
5862
cat.thread_pool:
5963
thread_pool_patterns: fetch*
60-
h: id,name,type,active,size,queue,queue_size,rejected,largest,completed,min,max,keep_alive
64+
h: id,name,type,active,pool_size,queue,queue_size,rejected,largest,completed,core,max,size,keep_alive
6165
v: true
6266

6367
- match:
6468
$body: |
65-
/^ id \s+ name \s+ type \s+ active \s+ size \s+ queue \s+ queue_size \s+ rejected \s+ largest \s+ completed \s+ min \s+ max \s+ keep_alive \n
66-
(\S+ \s+ fetch_shard_started \s+ scaling \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \S* \n
67-
\S+ \s+ fetch_shard_store \s+ scaling \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \S* \n)+ $/
69+
/^ id \s+ name \s+ type \s+ active \s+ pool_size \s+ queue \s+ queue_size \s+ rejected \s+ largest \s+ completed \s+ core \s+ max \s+ size \s+ keep_alive \n
70+
(\S+ \s+ fetch_shard_started \s+ scaling \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \d* \s+ \S* \n
71+
\S+ \s+ fetch_shard_store \s+ scaling \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \d* \s+ \S* \n)+ $/
6872
6973
- do:
7074
cat.thread_pool:

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

+31-8
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ public class InternalEngine extends Engine {
136136
private final AtomicLong maxSeqNoOfNonAppendOnlyOperations = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED);
137137
private final CounterMetric numVersionLookups = new CounterMetric();
138138
private final CounterMetric numIndexVersionsLookups = new CounterMetric();
139+
// Lucene operations since this engine was opened - not include operations from existing segments.
140+
private final CounterMetric numDocDeletes = new CounterMetric();
141+
private final CounterMetric numDocAppends = new CounterMetric();
142+
private final CounterMetric numDocUpdates = new CounterMetric();
143+
139144
/**
140145
* How many bytes we are currently moving to disk, via either IndexWriter.flush or refresh. IndexingMemoryController polls this
141146
* across all shards to decide if throttling is necessary because moving bytes to disk is falling behind vs incoming documents
@@ -907,11 +912,11 @@ private IndexResult indexIntoLucene(Index index, IndexingStrategy plan)
907912
index.parsedDoc().version().setLongValue(plan.versionForIndexing);
908913
try {
909914
if (plan.useLuceneUpdateDocument) {
910-
update(index.uid(), index.docs(), indexWriter);
915+
updateDocs(index.uid(), index.docs(), indexWriter);
911916
} else {
912917
// document does not exists, we can optimize for create, but double check if assertions are running
913918
assert assertDocDoesNotExist(index, canOptimizeAddDocument(index) == false);
914-
index(index.docs(), indexWriter);
919+
addDocs(index.docs(), indexWriter);
915920
}
916921
return new IndexResult(plan.versionForIndexing, plan.seqNoForIndexing, plan.currentNotFoundOrDeleted);
917922
} catch (Exception ex) {
@@ -968,12 +973,13 @@ long getMaxSeqNoOfNonAppendOnlyOperations() {
968973
return maxSeqNoOfNonAppendOnlyOperations.get();
969974
}
970975

971-
private static void index(final List<ParseContext.Document> docs, final IndexWriter indexWriter) throws IOException {
976+
private void addDocs(final List<ParseContext.Document> docs, final IndexWriter indexWriter) throws IOException {
972977
if (docs.size() > 1) {
973978
indexWriter.addDocuments(docs);
974979
} else {
975980
indexWriter.addDocument(docs.get(0));
976981
}
982+
numDocAppends.inc(docs.size());
977983
}
978984

979985
private static final class IndexingStrategy {
@@ -1054,12 +1060,13 @@ private boolean assertDocDoesNotExist(final Index index, final boolean allowDele
10541060
return true;
10551061
}
10561062

1057-
private static void update(final Term uid, final List<ParseContext.Document> docs, final IndexWriter indexWriter) throws IOException {
1063+
private void updateDocs(final Term uid, final List<ParseContext.Document> docs, final IndexWriter indexWriter) throws IOException {
10581064
if (docs.size() > 1) {
10591065
indexWriter.updateDocuments(uid, docs);
10601066
} else {
10611067
indexWriter.updateDocument(uid, docs.get(0));
10621068
}
1069+
numDocUpdates.inc(docs.size());
10631070
}
10641071

10651072
@Override
@@ -1188,6 +1195,7 @@ private DeleteResult deleteInLucene(Delete delete, DeletionStrategy plan)
11881195
// any exception that comes from this is a either an ACE or a fatal exception there
11891196
// can't be any document failures coming from this
11901197
indexWriter.deleteDocuments(delete.uid());
1198+
numDocDeletes.inc();
11911199
}
11921200
versionMap.putUnderLock(delete.uid().bytes(),
11931201
new DeleteVersionValue(plan.versionOfDeletion, plan.seqNoOfDeletion, delete.primaryTerm(),
@@ -2205,13 +2213,28 @@ boolean isSafeAccessRequired() {
22052213
return versionMap.isSafeAccessRequired();
22062214
}
22072215

2216+
/**
2217+
* Returns the number of documents have been deleted since this engine was opened.
2218+
* This count does not include the deletions from the existing segments before opening engine.
2219+
*/
2220+
long getNumDocDeletes() {
2221+
return numDocDeletes.count();
2222+
}
2223+
2224+
/**
2225+
* Returns the number of documents have been appended since this engine was opened.
2226+
* This count does not include the appends from the existing segments before opening engine.
2227+
*/
2228+
long getNumDocAppends() {
2229+
return numDocAppends.count();
2230+
}
22082231

22092232
/**
2210-
* Returns <code>true</code> iff the index writer has any deletions either buffered in memory or
2211-
* in the index.
2233+
* Returns the number of documents have been updated since this engine was opened.
2234+
* This count does not include the updates from the existing segments before opening engine.
22122235
*/
2213-
boolean indexWriterHasDeletions() {
2214-
return indexWriter.hasDeletions();
2236+
long getNumDocUpdates() {
2237+
return numDocUpdates.count();
22152238
}
22162239

22172240
@Override

server/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java

+19-12
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,15 @@ protected Table getTableWithHeader(final RestRequest request) {
124124
table.addCell("name", "default:true;alias:n;desc:thread pool name");
125125
table.addCell("type", "alias:t;default:false;desc:thread pool type");
126126
table.addCell("active", "alias:a;default:true;text-align:right;desc:number of active threads");
127-
table.addCell("size", "alias:s;default:false;text-align:right;desc:number of threads");
127+
table.addCell("pool_size", "alias:psz;default:false;text-align:right;desc:number of threads");
128128
table.addCell("queue", "alias:q;default:true;text-align:right;desc:number of tasks currently in queue");
129129
table.addCell("queue_size", "alias:qs;default:false;text-align:right;desc:maximum number of tasks permitted in queue");
130130
table.addCell("rejected", "alias:r;default:true;text-align:right;desc:number of rejected tasks");
131131
table.addCell("largest", "alias:l;default:false;text-align:right;desc:highest number of seen active threads");
132132
table.addCell("completed", "alias:c;default:false;text-align:right;desc:number of completed tasks");
133-
table.addCell("min", "alias:mi;default:false;text-align:right;desc:minimum number of threads");
134-
table.addCell("max", "alias:ma;default:false;text-align:right;desc:maximum number of threads");
133+
table.addCell("core", "alias:cr;default:false;text-align:right;desc:core number of threads in a scaling thread pool");
134+
table.addCell("max", "alias:mx;default:false;text-align:right;desc:maximum number of threads in a scaling thread pool");
135+
table.addCell("size", "alias:sz;default:false;text-align:right;desc:number of threads in a fixed thread pool");
135136
table.addCell("keep_alive", "alias:ka;default:false;text-align:right;desc:thread keep alive time");
136137
table.endHeaders();
137138
return table;
@@ -201,8 +202,9 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
201202

202203
Long maxQueueSize = null;
203204
String keepAlive = null;
204-
Integer minThreads = null;
205-
Integer maxThreads = null;
205+
Integer core = null;
206+
Integer max = null;
207+
Integer size = null;
206208

207209
if (poolInfo != null) {
208210
if (poolInfo.getQueueSize() != null) {
@@ -211,11 +213,15 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
211213
if (poolInfo.getKeepAlive() != null) {
212214
keepAlive = poolInfo.getKeepAlive().toString();
213215
}
214-
if (poolInfo.getMin() >= 0) {
215-
minThreads = poolInfo.getMin();
216-
}
217-
if (poolInfo.getMax() >= 0) {
218-
maxThreads = poolInfo.getMax();
216+
217+
if (poolInfo.getThreadPoolType() == ThreadPool.ThreadPoolType.SCALING) {
218+
assert poolInfo.getMin() >= 0;
219+
core = poolInfo.getMin();
220+
assert poolInfo.getMax() > 0;
221+
max = poolInfo.getMax();
222+
} else {
223+
assert poolInfo.getMin() == poolInfo.getMax() && poolInfo.getMax() > 0;
224+
size = poolInfo.getMax();
219225
}
220226
}
221227

@@ -228,8 +234,9 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
228234
table.addCell(poolStats == null ? null : poolStats.getRejected());
229235
table.addCell(poolStats == null ? null : poolStats.getLargest());
230236
table.addCell(poolStats == null ? null : poolStats.getCompleted());
231-
table.addCell(minThreads);
232-
table.addCell(maxThreads);
237+
table.addCell(core);
238+
table.addCell(max);
239+
table.addCell(size);
233240
table.addCell(keepAlive);
234241

235242
table.endRow();

0 commit comments

Comments
 (0)