Skip to content

Commit

Permalink
Add extra attempts to store into IC for flakiness avoidance (#1217)
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
  • Loading branch information
PetrShumilov authored Jan 17, 2025
1 parent 558e679 commit c869bf0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ function test_shared_memory_piece_copying() {
* @var $instance SomeContext
*/
$instance = instance_cache_fetch(SomeContext::class, "test_$i");
if ($instance === null) {
raise_error("Expected instance by key 'test_" . $i . "' hasn't been restored from instance cache");
}
for ($i = 0; $i < 100; $i++) {
if ($instance->some_data[$i] !== $some_data[$i]) {
raise_error("Data was changed in instance cache");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ function run_shared_memory_piece_copying_job(JobRequest $req) {
break;
}
case "instance_cache:instance": {
instance_cache_store("test_" . $req->id, $req->shared_memory_context->instance);
// The Instance Cache does not guarantee immediate and in-place data storage.
// To avoid flakiness, we need to ensure that key-value pairs are stored.
// Attempt storage for up to 1 second.
$t = time();
while (!instance_cache_store("test_" . $req->id, $req->shared_memory_context->instance) && time() - $t <= 1) {}
break;
}
}
Expand Down

0 comments on commit c869bf0

Please sign in to comment.