Fix clock used in update requests (#45262)
We accidentally switched to using the relative time provider here. This commit fixes this by switching to the appropriate absolute clock.
This commit is contained in:
parent
9318192578
commit
bd59ee6c72
|
@ -74,3 +74,22 @@
|
|||
id: 3
|
||||
|
||||
- match: { _source.has_now: true }
|
||||
|
||||
- do:
|
||||
update:
|
||||
index: test_1
|
||||
id: 4
|
||||
body:
|
||||
script:
|
||||
# assume _now is an absolute clock if it's in the range [now - 1m, now]; this tolerance might need adjustment after CI cycles
|
||||
source: "long now = System.currentTimeMillis();ctx._source.within_one_minute = ctx._now <= now && ctx._now >= now - 1000 * 60 * 1"
|
||||
lang: "painless"
|
||||
upsert: { within_one_minute: false }
|
||||
scripted_upsert: true
|
||||
|
||||
- do:
|
||||
get:
|
||||
index: test_1
|
||||
id: 4
|
||||
|
||||
- match: { _source.within_one_minute: true }
|
||||
|
|
|
@ -115,7 +115,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
protected void shardOperationOnPrimary(BulkShardRequest request, IndexShard primary,
|
||||
ActionListener<PrimaryResult<BulkShardRequest, BulkShardResponse>> listener) {
|
||||
ClusterStateObserver observer = new ClusterStateObserver(clusterService, request.timeout(), logger, threadPool.getThreadContext());
|
||||
performOnPrimary(request, primary, updateHelper, threadPool::relativeTimeInMillis,
|
||||
performOnPrimary(request, primary, updateHelper, threadPool::absoluteTimeInMillis,
|
||||
(update, shardId, type, mappingListener) -> {
|
||||
assert update != null;
|
||||
assert shardId != null;
|
||||
|
|
|
@ -348,7 +348,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
BulkPrimaryExecutionContext context = new BulkPrimaryExecutionContext(bulkShardRequest, shard);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
TransportShardBulkAction.executeBulkItemRequest(
|
||||
context, null, threadPool::relativeTimeInMillis,
|
||||
context, null, threadPool::absoluteTimeInMillis,
|
||||
errorOnWait == false ? new ThrowingMappingUpdatePerformer(err) : new NoopMappingUpdatePerformer(),
|
||||
errorOnWait ? listener -> listener.onFailure(err) : listener -> listener.onResponse(null),
|
||||
new LatchedActionListener<>(new ActionListener<Void>() {
|
||||
|
|
Loading…
Reference in New Issue