-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Introduce translog no-op #22291
Introduce translog no-op #22291
Changes from all commits
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 |
---|---|---|
|
@@ -277,7 +277,7 @@ private void recoverFromTranslog(TranslogRecoveryPerformer handler) throws IOExc | |
} | ||
// flush if we recovered something or if we have references to older translogs | ||
// note: if opsRecovered == 0 and we have older translogs it means they are corrupted or 0 length. | ||
assert pendingTranslogRecovery.get(): "translogRecovery is not pending but should be"; | ||
assert pendingTranslogRecovery.get() : "translogRecovery is not pending but should be"; | ||
pendingTranslogRecovery.set(false); // we are good - now we can commit | ||
if (opsRecovered > 0) { | ||
logger.trace("flushing post recovery from translog. ops recovered [{}]. committed translog id [{}]. current id [{}]", | ||
|
@@ -375,7 +375,7 @@ private static SeqNoStats loadSeqNoStatsFromLuceneAndTranslog( | |
* specified global checkpoint. | ||
* | ||
* @param globalCheckpoint the global checkpoint to use | ||
* @param indexWriter the index writer (for the Lucene commit point) | ||
* @param indexWriter the index writer (for the Lucene commit point) | ||
* @return the sequence number stats | ||
*/ | ||
private static SeqNoStats loadSeqNoStatsFromLucene(final long globalCheckpoint, final IndexWriter indexWriter) { | ||
|
@@ -434,7 +434,7 @@ public GetResult get(Get get, Function<String, Searcher> searcherFactory) throws | |
if (get.versionType().isVersionConflictForReads(versionValue.version(), get.version())) { | ||
Uid uid = Uid.createUid(get.uid().text()); | ||
throw new VersionConflictEngineException(shardId, uid.type(), uid.id(), | ||
get.versionType().explainConflictForReads(versionValue.version(), get.version())); | ||
get.versionType().explainConflictForReads(versionValue.version(), get.version())); | ||
} | ||
refresh("realtime_get"); | ||
} | ||
|
@@ -532,7 +532,7 @@ public IndexResult index(Index index) { | |
* | ||
* @return failure if the failure is a document specific failure (e.g. analysis chain failure) | ||
* or throws Exception if the failure caused the engine to fail (e.g. out of disk, lucene tragic event) | ||
* | ||
* <p> | ||
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. nit: remove? 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 guess the IDE did that? I will remove. |
||
* Note: pkg-private for testing | ||
*/ | ||
final Exception checkIfDocumentFailureOrThrow(final Operation operation, final Exception failure) { | ||
|
@@ -577,7 +577,7 @@ private boolean canOptimizeAddDocument(Index index) { | |
case PEER_RECOVERY: | ||
case REPLICA: | ||
assert index.version() == 1 && index.versionType() == VersionType.EXTERNAL | ||
: "version: " + index.version() + " type: " + index.versionType(); | ||
: "version: " + index.version() + " type: " + index.versionType(); | ||
return true; | ||
case LOCAL_TRANSLOG_RECOVERY: | ||
assert index.isRetry(); | ||
|
@@ -596,10 +596,10 @@ private boolean assertSequenceNumber(final Engine.Operation.Origin origin, final | |
" index version: " + engineConfig.getIndexSettings().getIndexVersionCreated() + ". seq no: " + seqNo; | ||
} else if (origin == Operation.Origin.PRIMARY) { | ||
// sequence number should not be set when operation origin is primary | ||
assert seqNo == SequenceNumbersService.UNASSIGNED_SEQ_NO : "primary ops should never an assigned seq no. got: " + seqNo; | ||
assert seqNo == SequenceNumbersService.UNASSIGNED_SEQ_NO : "primary ops should never have an assigned seq no. got: " + seqNo; | ||
} else { | ||
// sequence number should be set when operation origin is not primary | ||
assert seqNo >= 0 : "replica ops should an assigned seq no. origin: " + origin + | ||
assert seqNo >= 0 : "recovery or replica ops should have an assigned seq no. origin: " + origin + | ||
" index version: " + engineConfig.getIndexSettings().getIndexVersionCreated(); | ||
} | ||
return true; | ||
|
@@ -651,7 +651,7 @@ private IndexResult innerIndex(Index index) throws IOException { | |
if (deOptimizeTimestamp >= index.getAutoGeneratedIdTimestamp()) { | ||
break; | ||
} | ||
} while(maxUnsafeAutoIdTimestamp.compareAndSet(deOptimizeTimestamp, | ||
} while (maxUnsafeAutoIdTimestamp.compareAndSet(deOptimizeTimestamp, | ||
index.getAutoGeneratedIdTimestamp()) == false); | ||
assert maxUnsafeAutoIdTimestamp.get() >= index.getAutoGeneratedIdTimestamp(); | ||
} else { | ||
|
@@ -859,6 +859,34 @@ private boolean deleteIfFound(Term uid, long currentVersion, boolean deleted, Ve | |
return found; | ||
} | ||
|
||
@Override | ||
public NoOpResult noOp(final NoOp noOp) { | ||
NoOpResult noOpResult; | ||
try (final ReleasableLock ignored = readLock.acquire()) { | ||
noOpResult = innerNoOp(noOp); | ||
} catch (final Exception e) { | ||
noOpResult = new NoOpResult(noOp.seqNo(), e); | ||
} | ||
return noOpResult; | ||
} | ||
|
||
private NoOpResult innerNoOp(final NoOp noOp) throws IOException { | ||
assert noOp.seqNo() > SequenceNumbersService.NO_OPS_PERFORMED; | ||
final long seqNo = noOp.seqNo(); | ||
try { | ||
final NoOpResult noOpResult = new NoOpResult(noOp.seqNo()); | ||
final Translog.Location location = translog.add(new Translog.NoOp(noOp.seqNo(), noOp.primaryTerm(), noOp.reason())); | ||
noOpResult.setTranslogLocation(location); | ||
noOpResult.setTook(System.nanoTime() - noOp.startTime()); | ||
noOpResult.freeze(); | ||
return noOpResult; | ||
} finally { | ||
if (seqNo != SequenceNumbersService.UNASSIGNED_SEQ_NO) { | ||
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. seq no must be assigned here, no? 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. Yes, but I prefer the symmetry with 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. ok. |
||
seqNoService().markSeqNoAsCompleted(seqNo); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void refresh(String source) throws EngineException { | ||
// we obtain a read lock here, since we don't want a flush to happen while we are refreshing | ||
|
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.
nit: comment needs updating
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 updated this comment.