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
Add logging around gateway shard allocation #9562
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -630,6 +630,7 @@ ImmutableMap<String, StoreFileMetaData> buildMetadata(IndexCommit commit, Direct | |
// Lucene checks the checksum after it tries to lookup the codec etc. | ||
// in that case we might get only IAE or similar exceptions while we are really corrupt... | ||
// TODO we should check the checksum in lucene if we hit an exception | ||
logger.warn("checking segment info integrity (reason [{}])", ex.getMessage()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would log the exception here, not just the message, it will provide much more details, and its bad if it happens I would imagine. Also, I would try and explain it better in the logging, for example, tried to do lightweight check, but failed, resorting to full checksum |
||
Lucene.checkSegmentInfoIntegrity(directory); | ||
} catch (CorruptIndexException cex) { | ||
cex.addSuppressed(ex); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,10 @@ | |
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.*; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.atomic.AtomicReferenceArray; | ||
|
||
/** | ||
|
@@ -142,44 +145,56 @@ protected NodeStoreFilesMetaData nodeOperation(NodeRequest request) throws Elast | |
} | ||
|
||
private StoreFilesMetaData listStoreMetaData(ShardId shardId) throws IOException { | ||
IndexService indexService = indicesService.indexService(shardId.index().name()); | ||
if (indexService != null) { | ||
InternalIndexShard indexShard = (InternalIndexShard) indexService.shard(shardId.id()); | ||
if (indexShard != null) { | ||
final Store store = indexShard.store(); | ||
store.incRef(); | ||
try { | ||
return new StoreFilesMetaData(true, shardId, store.getMetadataOrEmpty().asMap()); | ||
} finally { | ||
store.decRef(); | ||
logger.trace("listing store meta data for {}", shardId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here as well :) |
||
long startTime = System.currentTimeMillis(); | ||
boolean exists = false; | ||
try { | ||
IndexService indexService = indicesService.indexService(shardId.index().name()); | ||
if (indexService != null) { | ||
InternalIndexShard indexShard = (InternalIndexShard) indexService.shard(shardId.id()); | ||
if (indexShard != null) { | ||
final Store store = indexShard.store(); | ||
store.incRef(); | ||
try { | ||
exists = true; | ||
return new StoreFilesMetaData(true, shardId, store.getMetadataOrEmpty().asMap()); | ||
} finally { | ||
store.decRef(); | ||
} | ||
} | ||
} | ||
} | ||
// try and see if we an list unallocated | ||
IndexMetaData metaData = clusterService.state().metaData().index(shardId.index().name()); | ||
if (metaData == null) { | ||
return new StoreFilesMetaData(false, shardId, ImmutableMap.<String, StoreFileMetaData>of()); | ||
} | ||
String storeType = metaData.settings().get("index.store.type", "fs"); | ||
if (!storeType.contains("fs")) { | ||
return new StoreFilesMetaData(false, shardId, ImmutableMap.<String, StoreFileMetaData>of()); | ||
} | ||
File[] shardLocations = nodeEnv.shardLocations(shardId); | ||
File[] shardIndexLocations = new File[shardLocations.length]; | ||
for (int i = 0; i < shardLocations.length; i++) { | ||
shardIndexLocations[i] = new File(shardLocations[i], "index"); | ||
} | ||
boolean exists = false; | ||
for (File shardIndexLocation : shardIndexLocations) { | ||
if (shardIndexLocation.exists()) { | ||
exists = true; | ||
break; | ||
// try and see if we an list unallocated | ||
IndexMetaData metaData = clusterService.state().metaData().index(shardId.index().name()); | ||
if (metaData == null) { | ||
return new StoreFilesMetaData(false, shardId, ImmutableMap.<String, StoreFileMetaData>of()); | ||
} | ||
String storeType = metaData.settings().get("index.store.type", "fs"); | ||
if (!storeType.contains("fs")) { | ||
return new StoreFilesMetaData(false, shardId, ImmutableMap.<String, StoreFileMetaData>of()); | ||
} | ||
File[] shardLocations = nodeEnv.shardLocations(shardId); | ||
File[] shardIndexLocations = new File[shardLocations.length]; | ||
for (int i = 0; i < shardLocations.length; i++) { | ||
shardIndexLocations[i] = new File(shardLocations[i], "index"); | ||
} | ||
for (File shardIndexLocation : shardIndexLocations) { | ||
if (shardIndexLocation.exists()) { | ||
exists = true; | ||
break; | ||
} | ||
} | ||
if (!exists) { | ||
return new StoreFilesMetaData(false, shardId, ImmutableMap.<String, StoreFileMetaData>of()); | ||
} | ||
return new StoreFilesMetaData(false, shardId, Store.readMetadataSnapshot(shardIndexLocations, logger).asMap()); | ||
} finally { | ||
TimeValue took = new TimeValue(System.currentTimeMillis() - startTime); | ||
if (exists) { | ||
logger.debug("loaded store meta data for {} (took [{}])", shardId, took); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this log message, and the next one, we are not consistent with our logging messages, when we log something in the context of a shard, its the first thing in the log line, can we please fix it and do: |
||
} else { | ||
logger.trace("loaded store meta data for {} (took [{}])", shardId, took); | ||
} | ||
} | ||
if (!exists) { | ||
return new StoreFilesMetaData(false, shardId, ImmutableMap.<String, StoreFileMetaData>of()); | ||
} | ||
return new StoreFilesMetaData(false, shardId, Store.readMetadataSnapshot(shardIndexLocations, logger).asMap()); | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use
ExceptionsHelper#detailedMessage
to now miss when this get wrapped in inner exceptions?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My goal here was to keep it brief. We already get a full trace in the log message above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I Am concerned that we will miss the actual message because its wrapped, my vote is the detailed message one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case we change the log message on logListActionFailures to log the entire exception. It's the difference between detailedMessage and just a message. But putting the detail in the message the choice is gone. Do agree with solving this on the logging side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, in that case, let's not add the addition message, and solve it on the logging side m