mirror of
https://github.com/wassname/ray.git
synced 2026-08-08 11:25:28 +08:00
[Core] Remove delete_creating_tasks (#12962)
This commit is contained in:
@@ -72,9 +72,8 @@ public interface RayRuntime {
|
||||
*
|
||||
* @param objectRefs The object references to free.
|
||||
* @param localOnly Whether only free objects for local object store or not.
|
||||
* @param deleteCreatingTasks Whether also delete objects' creating tasks from GCS.
|
||||
*/
|
||||
void free(List<ObjectRef<?>> objectRefs, boolean localOnly, boolean deleteCreatingTasks);
|
||||
void free(List<ObjectRef<?>> objectRefs, boolean localOnly);
|
||||
|
||||
/**
|
||||
* Set the resource for the specific node.
|
||||
|
||||
@@ -100,9 +100,9 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void free(List<ObjectRef<?>> objectRefs, boolean localOnly, boolean deleteCreatingTasks) {
|
||||
public void free(List<ObjectRef<?>> objectRefs, boolean localOnly) {
|
||||
objectStore.delete(objectRefs.stream().map(ref -> ((ObjectRefImpl<?>) ref).getId()).collect(
|
||||
Collectors.toList()), localOnly, deleteCreatingTasks);
|
||||
Collectors.toList()), localOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,10 +3,8 @@ package io.ray.runtime.gcs;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import io.ray.api.id.ActorId;
|
||||
import io.ray.api.id.BaseId;
|
||||
import io.ray.api.id.JobId;
|
||||
import io.ray.api.id.PlacementGroupId;
|
||||
import io.ray.api.id.TaskId;
|
||||
import io.ray.api.id.UniqueId;
|
||||
import io.ray.api.placementgroup.PlacementGroup;
|
||||
import io.ray.api.runtimecontext.NodeInfo;
|
||||
@@ -14,12 +12,10 @@ import io.ray.runtime.generated.Gcs;
|
||||
import io.ray.runtime.generated.Gcs.GcsNodeInfo;
|
||||
import io.ray.runtime.generated.Gcs.TablePrefix;
|
||||
import io.ray.runtime.placementgroup.PlacementGroupUtils;
|
||||
import io.ray.runtime.util.IdUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -31,25 +27,10 @@ public class GcsClient {
|
||||
private static Logger LOGGER = LoggerFactory.getLogger(GcsClient.class);
|
||||
private RedisClient primary;
|
||||
|
||||
private List<RedisClient> shards;
|
||||
private GlobalStateAccessor globalStateAccessor;
|
||||
|
||||
public GcsClient(String redisAddress, String redisPassword) {
|
||||
primary = new RedisClient(redisAddress, redisPassword);
|
||||
int numShards = 0;
|
||||
try {
|
||||
numShards = Integer.valueOf(primary.get("NumRedisShards", null));
|
||||
Preconditions.checkState(numShards > 0,
|
||||
String.format("Expected at least one Redis shards, found %d.", numShards));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException("Failed to get number of redis shards.", e);
|
||||
}
|
||||
|
||||
List<byte[]> shardAddresses = primary.lrange("RedisShards".getBytes(), 0, -1);
|
||||
Preconditions.checkState(shardAddresses.size() == numShards);
|
||||
shards = shardAddresses.stream().map((byte[] address) -> {
|
||||
return new RedisClient(new String(address), redisPassword);
|
||||
}).collect(Collectors.toList());
|
||||
globalStateAccessor = GlobalStateAccessor.getInstance(redisAddress, redisPassword);
|
||||
}
|
||||
|
||||
@@ -163,16 +144,6 @@ public class GcsClient {
|
||||
return actorTableData.getNumRestarts() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query whether the raylet task exists in Gcs.
|
||||
*/
|
||||
public boolean rayletTaskExistsInGcs(TaskId taskId) {
|
||||
byte[] key = ArrayUtils.addAll(TablePrefix.RAYLET_TASK.toString().getBytes(),
|
||||
taskId.getBytes());
|
||||
RedisClient client = getShardClient(taskId);
|
||||
return client.exists(key);
|
||||
}
|
||||
|
||||
public JobId nextJobId() {
|
||||
int jobCounter = (int) primary.incr("JobCounter".getBytes());
|
||||
return JobId.fromInt(jobCounter);
|
||||
@@ -186,10 +157,4 @@ public class GcsClient {
|
||||
LOGGER.debug("Destroying global state accessor.");
|
||||
GlobalStateAccessor.destroyInstance();
|
||||
}
|
||||
|
||||
private RedisClient getShardClient(BaseId key) {
|
||||
return shards.get((int) Long.remainderUnsigned(IdUtil.murmurHashCode(key),
|
||||
shards.size()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class LocalModeObjectStore extends ObjectStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<ObjectId> objectIds, boolean localOnly, boolean deleteCreatingTasks) {
|
||||
public void delete(List<ObjectId> objectIds, boolean localOnly) {
|
||||
for (ObjectId objectId : objectIds) {
|
||||
pool.remove(objectId);
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ public class NativeObjectStore extends ObjectStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<ObjectId> objectIds, boolean localOnly, boolean deleteCreatingTasks) {
|
||||
nativeDelete(toBinaryList(objectIds), localOnly, deleteCreatingTasks);
|
||||
public void delete(List<ObjectId> objectIds, boolean localOnly) {
|
||||
nativeDelete(toBinaryList(objectIds), localOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,8 +116,7 @@ public class NativeObjectStore extends ObjectStore {
|
||||
private static native List<Boolean> nativeWait(List<byte[]> objectIds, int numObjects,
|
||||
long timeoutMs);
|
||||
|
||||
private static native void nativeDelete(List<byte[]> objectIds, boolean localOnly,
|
||||
boolean deleteCreatingTasks);
|
||||
private static native void nativeDelete(List<byte[]> objectIds, boolean localOnly);
|
||||
|
||||
private static native void nativeAddLocalReference(byte[] workerId, byte[] objectId);
|
||||
|
||||
|
||||
@@ -167,10 +167,8 @@ public abstract class ObjectStore {
|
||||
*
|
||||
* @param objectIds IDs of the objects to delete.
|
||||
* @param localOnly Whether only delete the objects in local node, or all nodes in the cluster.
|
||||
* @param deleteCreatingTasks Whether also delete the tasks that created these objects.
|
||||
*/
|
||||
public abstract void delete(List<ObjectId> objectIds, boolean localOnly,
|
||||
boolean deleteCreatingTasks);
|
||||
public abstract void delete(List<ObjectId> objectIds, boolean localOnly);
|
||||
|
||||
/**
|
||||
* Increase the local reference count for this object ID.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ray.runtime.util;
|
||||
|
||||
import io.ray.api.id.ActorId;
|
||||
import io.ray.api.id.BaseId;
|
||||
import io.ray.api.id.ObjectId;
|
||||
import io.ray.api.id.TaskId;
|
||||
|
||||
@@ -11,74 +10,6 @@ import io.ray.api.id.TaskId;
|
||||
*/
|
||||
public class IdUtil {
|
||||
|
||||
/**
|
||||
* Compute the murmur hash code of this ID.
|
||||
*/
|
||||
public static long murmurHashCode(BaseId id) {
|
||||
return murmurHash64A(id.getBytes(), id.size(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is the same as `Hash()` method of `ID` class in ray/src/ray/common/id.h
|
||||
*/
|
||||
private static long murmurHash64A(byte[] data, int length, int seed) {
|
||||
final long m = 0xc6a4a7935bd1e995L;
|
||||
final int r = 47;
|
||||
|
||||
long h = (seed & 0xFFFFFFFFL) ^ (length * m);
|
||||
|
||||
int length8 = length / 8;
|
||||
|
||||
for (int i = 0; i < length8; i++) {
|
||||
final int i8 = i * 8;
|
||||
long k = ((long) data[i8] & 0xff)
|
||||
+ (((long) data[i8 + 1] & 0xff) << 8)
|
||||
+ (((long) data[i8 + 2] & 0xff) << 16)
|
||||
+ (((long) data[i8 + 3] & 0xff) << 24)
|
||||
+ (((long) data[i8 + 4] & 0xff) << 32)
|
||||
+ (((long) data[i8 + 5] & 0xff) << 40)
|
||||
+ (((long) data[i8 + 6] & 0xff) << 48)
|
||||
+ (((long) data[i8 + 7] & 0xff) << 56);
|
||||
|
||||
k *= m;
|
||||
k ^= k >>> r;
|
||||
k *= m;
|
||||
|
||||
h ^= k;
|
||||
h *= m;
|
||||
}
|
||||
|
||||
final int remaining = length % 8;
|
||||
if (remaining >= 7) {
|
||||
h ^= (long) (data[(length & ~7) + 6] & 0xff) << 48;
|
||||
}
|
||||
if (remaining >= 6) {
|
||||
h ^= (long) (data[(length & ~7) + 5] & 0xff) << 40;
|
||||
}
|
||||
if (remaining >= 5) {
|
||||
h ^= (long) (data[(length & ~7) + 4] & 0xff) << 32;
|
||||
}
|
||||
if (remaining >= 4) {
|
||||
h ^= (long) (data[(length & ~7) + 3] & 0xff) << 24;
|
||||
}
|
||||
if (remaining >= 3) {
|
||||
h ^= (long) (data[(length & ~7) + 2] & 0xff) << 16;
|
||||
}
|
||||
if (remaining >= 2) {
|
||||
h ^= (long) (data[(length & ~7) + 1] & 0xff) << 8;
|
||||
}
|
||||
if (remaining >= 1) {
|
||||
h ^= (long) (data[length & ~7] & 0xff);
|
||||
h *= m;
|
||||
}
|
||||
|
||||
h ^= h >>> r;
|
||||
h *= m;
|
||||
h ^= h >>> r;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the actor ID of the task which created this object.
|
||||
* @return The actor ID of the task which created this object.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ray.runtime;
|
||||
|
||||
import io.ray.api.id.UniqueId;
|
||||
import io.ray.runtime.util.IdUtil;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
@@ -46,11 +45,4 @@ public class UniqueIdTest {
|
||||
Assert.assertEquals("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF".toLowerCase(), id6.toString());
|
||||
Assert.assertTrue(id6.isNil());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMurmurHash() {
|
||||
UniqueId id = UniqueId.fromHexString("3131313131313131313132323232323232323232");
|
||||
long remainder = Long.remainderUnsigned(IdUtil.murmurHashCode(id), 1000000000);
|
||||
Assert.assertEquals(remainder, 787616861);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ActorTest extends BaseTest {
|
||||
ObjectRef value = counter.task(Counter::getValue).remote();
|
||||
Assert.assertEquals(100, value.get());
|
||||
// Delete the object from the object store.
|
||||
Ray.internal().free(ImmutableList.of(value), false, false);
|
||||
Ray.internal().free(ImmutableList.of(value), false);
|
||||
// Wait for delete RPC to propagate
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
// Free deletes from in-memory store.
|
||||
@@ -138,7 +138,7 @@ public class ActorTest extends BaseTest {
|
||||
ObjectRef<TestUtils.LargeObject> largeValue = counter.task(Counter::createLargeObject).remote();
|
||||
Assert.assertTrue(largeValue.get() instanceof TestUtils.LargeObject);
|
||||
// Delete the object from the object store.
|
||||
Ray.internal().free(ImmutableList.of(largeValue), false, false);
|
||||
Ray.internal().free(ImmutableList.of(largeValue), false);
|
||||
// Wait for delete RPC to propagate
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
// Free deletes big objects from plasma store.
|
||||
|
||||
@@ -3,9 +3,7 @@ package io.ray.test;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.api.id.TaskId;
|
||||
import io.ray.runtime.object.ObjectRefImpl;
|
||||
import java.util.Arrays;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -20,7 +18,7 @@ public class PlasmaFreeTest extends BaseTest {
|
||||
ObjectRef<String> helloId = Ray.task(PlasmaFreeTest::hello).remote();
|
||||
String helloString = helloId.get();
|
||||
Assert.assertEquals("hello", helloString);
|
||||
Ray.internal().free(ImmutableList.of(helloId), true, false);
|
||||
Ray.internal().free(ImmutableList.of(helloId), true);
|
||||
|
||||
final boolean result = TestUtils.waitForCondition(() ->
|
||||
!TestUtils.getRuntime().getObjectStore()
|
||||
@@ -32,19 +30,4 @@ public class PlasmaFreeTest extends BaseTest {
|
||||
Assert.assertFalse(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(groups = {"cluster"})
|
||||
public void testDeleteCreatingTasks() {
|
||||
ObjectRef<String> helloId = Ray.task(PlasmaFreeTest::hello).remote();
|
||||
Assert.assertEquals("hello", helloId.get());
|
||||
Ray.internal().free(ImmutableList.of(helloId), true, true);
|
||||
|
||||
TaskId taskId = TaskId.fromBytes(
|
||||
Arrays.copyOf(((ObjectRefImpl<String>) helloId).getId().getBytes(), TaskId.LENGTH));
|
||||
final boolean result = TestUtils.waitForCondition(
|
||||
() -> !TestUtils.getRuntime().getGcsClient()
|
||||
.rayletTaskExistsInGcs(taskId), 50);
|
||||
Assert.assertTrue(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1031,14 +1031,13 @@ cdef class CoreWorker:
|
||||
|
||||
return ready, not_ready
|
||||
|
||||
def free_objects(self, object_refs, c_bool local_only,
|
||||
c_bool delete_creating_tasks):
|
||||
def free_objects(self, object_refs, c_bool local_only):
|
||||
cdef:
|
||||
c_vector[CObjectID] free_ids = ObjectRefsToVector(object_refs)
|
||||
|
||||
with nogil:
|
||||
check_status(CCoreWorkerProcess.GetCoreWorker().Delete(
|
||||
free_ids, local_only, delete_creating_tasks))
|
||||
free_ids, local_only))
|
||||
|
||||
def global_gc(self):
|
||||
with nogil:
|
||||
|
||||
@@ -182,7 +182,7 @@ cdef extern from "ray/core_worker/core_worker.h" nogil:
|
||||
int64_t timeout_ms, c_vector[c_bool] *results,
|
||||
c_bool fetch_local)
|
||||
CRayStatus Delete(const c_vector[CObjectID] &object_ids,
|
||||
c_bool local_only, c_bool delete_creating_tasks)
|
||||
c_bool local_only)
|
||||
CRayStatus TriggerGlobalGC()
|
||||
c_string MemoryUsageString()
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ def memory_summary():
|
||||
return reply.memory_summary
|
||||
|
||||
|
||||
def free(object_refs, local_only=False, delete_creating_tasks=False):
|
||||
def free(object_refs, local_only=False):
|
||||
"""Free a list of IDs from the in-process and plasma object stores.
|
||||
|
||||
This function is a low-level API which should be used in restricted
|
||||
@@ -59,8 +59,6 @@ def free(object_refs, local_only=False, delete_creating_tasks=False):
|
||||
object_refs (List[ObjectRef]): List of object refs to delete.
|
||||
local_only (bool): Whether only deleting the list of objects in local
|
||||
object store or all object stores.
|
||||
delete_creating_tasks (bool): Whether also delete the object creating
|
||||
tasks.
|
||||
"""
|
||||
worker = ray.worker.global_worker
|
||||
|
||||
@@ -83,5 +81,4 @@ def free(object_refs, local_only=False, delete_creating_tasks=False):
|
||||
if len(object_refs) == 0:
|
||||
return
|
||||
|
||||
worker.core_worker.free_objects(object_refs, local_only,
|
||||
delete_creating_tasks)
|
||||
worker.core_worker.free_objects(object_refs, local_only)
|
||||
|
||||
@@ -1111,8 +1111,7 @@ Status CoreWorker::Wait(const std::vector<ObjectID> &ids, int num_objects,
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status CoreWorker::Delete(const std::vector<ObjectID> &object_ids, bool local_only,
|
||||
bool delete_creating_tasks) {
|
||||
Status CoreWorker::Delete(const std::vector<ObjectID> &object_ids, bool local_only) {
|
||||
// Release the object from plasma. This does not affect the object's ref
|
||||
// count. If this was called from a non-owning worker, then a warning will be
|
||||
// logged and the object will not get released.
|
||||
@@ -1129,8 +1128,7 @@ Status CoreWorker::Delete(const std::vector<ObjectID> &object_ids, bool local_on
|
||||
// We only delete from plasma, which avoids hangs (issue #7105). In-memory
|
||||
// objects can only be deleted once the ref count goes to 0.
|
||||
absl::flat_hash_set<ObjectID> plasma_object_ids(object_ids.begin(), object_ids.end());
|
||||
return plasma_store_provider_->Delete(plasma_object_ids, local_only,
|
||||
delete_creating_tasks);
|
||||
return plasma_store_provider_->Delete(plasma_object_ids, local_only);
|
||||
}
|
||||
|
||||
void CoreWorker::TriggerGlobalGC() {
|
||||
|
||||
@@ -571,11 +571,8 @@ class CoreWorker : public rpc::CoreWorkerServiceHandler {
|
||||
/// \param[in] object_ids IDs of the objects to delete.
|
||||
/// \param[in] local_only Whether only delete the objects in local node, or all nodes in
|
||||
/// the cluster.
|
||||
/// \param[in] delete_creating_tasks Whether also delete the tasks that
|
||||
/// created these objects.
|
||||
/// \return Status.
|
||||
Status Delete(const std::vector<ObjectID> &object_ids, bool local_only,
|
||||
bool delete_creating_tasks);
|
||||
Status Delete(const std::vector<ObjectID> &object_ids, bool local_only);
|
||||
|
||||
/// Trigger garbage collection on each worker in the cluster.
|
||||
void TriggerGlobalGC();
|
||||
|
||||
@@ -120,15 +120,14 @@ JNIEXPORT jobject JNICALL Java_io_ray_runtime_object_NativeObjectStore_nativeWai
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_io_ray_runtime_object_NativeObjectStore_nativeDelete(
|
||||
JNIEnv *env, jclass, jobject objectIds, jboolean localOnly,
|
||||
jboolean deleteCreatingTasks) {
|
||||
JNIEnv *env, jclass, jobject objectIds, jboolean localOnly) {
|
||||
std::vector<ray::ObjectID> object_ids;
|
||||
JavaListToNativeVector<ray::ObjectID>(
|
||||
env, objectIds, &object_ids, [](JNIEnv *env, jobject id) {
|
||||
return JavaByteArrayToId<ray::ObjectID>(env, static_cast<jbyteArray>(id));
|
||||
});
|
||||
auto status = ray::CoreWorkerProcess::GetCoreWorker().Delete(
|
||||
object_ids, (bool)localOnly, (bool)deleteCreatingTasks);
|
||||
auto status =
|
||||
ray::CoreWorkerProcess::GetCoreWorker().Delete(object_ids, (bool)localOnly);
|
||||
THROW_EXCEPTION_AND_RETURN_IF_NOT_OK(env, status, (void)0);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ JNIEXPORT jobject JNICALL Java_io_ray_runtime_object_NativeObjectStore_nativeWai
|
||||
/*
|
||||
* Class: io_ray_runtime_object_NativeObjectStore
|
||||
* Method: nativeDelete
|
||||
* Signature: (Ljava/util/List;ZZ)V
|
||||
* Signature: (Ljava/util/List;Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_io_ray_runtime_object_NativeObjectStore_nativeDelete(
|
||||
JNIEnv *, jclass, jobject, jboolean, jboolean);
|
||||
JNIEnv *, jclass, jobject, jboolean);
|
||||
|
||||
/*
|
||||
* Class: io_ray_runtime_object_NativeObjectStore
|
||||
|
||||
@@ -361,10 +361,9 @@ Status CoreWorkerPlasmaStoreProvider::Wait(
|
||||
}
|
||||
|
||||
Status CoreWorkerPlasmaStoreProvider::Delete(
|
||||
const absl::flat_hash_set<ObjectID> &object_ids, bool local_only,
|
||||
bool delete_creating_tasks) {
|
||||
const absl::flat_hash_set<ObjectID> &object_ids, bool local_only) {
|
||||
std::vector<ObjectID> object_id_vector(object_ids.begin(), object_ids.end());
|
||||
return raylet_client_->FreeObjects(object_id_vector, local_only, delete_creating_tasks);
|
||||
return raylet_client_->FreeObjects(object_id_vector, local_only);
|
||||
}
|
||||
|
||||
std::string CoreWorkerPlasmaStoreProvider::MemoryUsageString() {
|
||||
@@ -424,7 +423,7 @@ Status CoreWorkerPlasmaStoreProvider::WarmupStore() {
|
||||
RAY_RETURN_NOT_OK(Create(nullptr, 8, object_id, rpc::Address(), &data));
|
||||
RAY_RETURN_NOT_OK(Seal(object_id));
|
||||
RAY_RETURN_NOT_OK(Release(object_id));
|
||||
RAY_RETURN_NOT_OK(Delete({object_id}, false, false));
|
||||
RAY_RETURN_NOT_OK(Delete({object_id}, false));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +98,7 @@ class CoreWorkerPlasmaStoreProvider {
|
||||
int64_t timeout_ms, const WorkerContext &ctx,
|
||||
absl::flat_hash_set<ObjectID> *ready);
|
||||
|
||||
Status Delete(const absl::flat_hash_set<ObjectID> &object_ids, bool local_only,
|
||||
bool delete_creating_tasks);
|
||||
Status Delete(const absl::flat_hash_set<ObjectID> &object_ids, bool local_only);
|
||||
|
||||
/// Lists objects in used (pinned) by the current client.
|
||||
///
|
||||
|
||||
@@ -822,7 +822,7 @@ TEST_F(SingleNodeTest, TestObjectInterface) {
|
||||
// Test Delete().
|
||||
// clear the reference held by PlasmaBuffer.
|
||||
results.clear();
|
||||
RAY_CHECK_OK(core_worker.Delete(ids, true, false));
|
||||
RAY_CHECK_OK(core_worker.Delete(ids, true));
|
||||
|
||||
// Note that Delete() calls RayletClient::FreeObjects and would not
|
||||
// wait for objects being deleted, so wait a while for plasma store
|
||||
|
||||
@@ -208,16 +208,6 @@ class TaskInfoAccessor {
|
||||
virtual Status AsyncGet(const TaskID &task_id,
|
||||
const OptionalItemCallback<rpc::TaskTableData> &callback) = 0;
|
||||
|
||||
/// Delete tasks from GCS asynchronously.
|
||||
///
|
||||
/// \param task_ids The vector of IDs to delete from GCS.
|
||||
/// \param callback Callback that is called after delete finished.
|
||||
/// \return Status
|
||||
// TODO(micafan) Will support callback of batch deletion in the future.
|
||||
// Currently this callback will never be called.
|
||||
virtual Status AsyncDelete(const std::vector<TaskID> &task_ids,
|
||||
const StatusCallback &callback) = 0;
|
||||
|
||||
/// Subscribe asynchronously to the event that the given task is added in GCS.
|
||||
///
|
||||
/// \param task_id The ID of the task to be subscribed to.
|
||||
|
||||
@@ -886,25 +886,6 @@ Status ServiceBasedTaskInfoAccessor::AsyncGet(
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status ServiceBasedTaskInfoAccessor::AsyncDelete(const std::vector<TaskID> &task_ids,
|
||||
const StatusCallback &callback) {
|
||||
RAY_LOG(DEBUG) << "Deleting tasks, task id list size = " << task_ids.size();
|
||||
rpc::DeleteTasksRequest request;
|
||||
for (auto &task_id : task_ids) {
|
||||
request.add_task_id_list(task_id.Binary());
|
||||
}
|
||||
client_impl_->GetGcsRpcClient().DeleteTasks(
|
||||
request,
|
||||
[task_ids, callback](const Status &status, const rpc::DeleteTasksReply &reply) {
|
||||
if (callback) {
|
||||
callback(status);
|
||||
}
|
||||
RAY_LOG(DEBUG) << "Finished deleting tasks, status = " << status
|
||||
<< ", task id list size = " << task_ids.size();
|
||||
});
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status ServiceBasedTaskInfoAccessor::AsyncSubscribe(
|
||||
const TaskID &task_id, const SubscribeCallback<TaskID, rpc::TaskTableData> &subscribe,
|
||||
const StatusCallback &done) {
|
||||
|
||||
@@ -278,9 +278,6 @@ class ServiceBasedTaskInfoAccessor : public TaskInfoAccessor {
|
||||
Status AsyncGet(const TaskID &task_id,
|
||||
const OptionalItemCallback<rpc::TaskTableData> &callback) override;
|
||||
|
||||
Status AsyncDelete(const std::vector<TaskID> &task_ids,
|
||||
const StatusCallback &callback) override;
|
||||
|
||||
Status AsyncSubscribe(const TaskID &task_id,
|
||||
const SubscribeCallback<TaskID, rpc::TaskTableData> &subscribe,
|
||||
const StatusCallback &done) override;
|
||||
|
||||
@@ -415,13 +415,6 @@ class ServiceBasedGcsClientTest : public ::testing::Test {
|
||||
return task_table_data;
|
||||
}
|
||||
|
||||
bool DeleteTask(const std::vector<TaskID> &task_ids) {
|
||||
std::promise<bool> promise;
|
||||
RAY_CHECK_OK(gcs_client_->Tasks().AsyncDelete(
|
||||
task_ids, [&promise](Status status) { promise.set_value(status.ok()); }));
|
||||
return WaitReady(promise.get_future(), timeout_ms_);
|
||||
}
|
||||
|
||||
bool SubscribeTaskLease(
|
||||
const TaskID &task_id,
|
||||
const gcs::SubscribeCallback<TaskID, boost::optional<rpc::TaskLeaseData>>
|
||||
@@ -875,10 +868,6 @@ TEST_F(ServiceBasedGcsClientTest, TestTaskInfo) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
EXPECT_EQ(task_count, 1);
|
||||
|
||||
// Delete tasks from GCS.
|
||||
std::vector<TaskID> task_ids = {task_id};
|
||||
ASSERT_TRUE(DeleteTask(task_ids));
|
||||
|
||||
// Subscribe to the event that the given task lease is added in GCS.
|
||||
std::atomic<int> task_lease_count(0);
|
||||
auto task_lease_subscribe = [&task_lease_count](
|
||||
|
||||
@@ -68,30 +68,6 @@ void DefaultTaskInfoHandler::HandleGetTask(const GetTaskRequest &request,
|
||||
++counts_[CountType::GET_TASK_REQUEST];
|
||||
}
|
||||
|
||||
void DefaultTaskInfoHandler::HandleDeleteTasks(const DeleteTasksRequest &request,
|
||||
DeleteTasksReply *reply,
|
||||
SendReplyCallback send_reply_callback) {
|
||||
std::vector<TaskID> task_ids = IdVectorFromProtobuf<TaskID>(request.task_id_list());
|
||||
JobID job_id = task_ids.empty() ? JobID::Nil() : task_ids[0].JobId();
|
||||
RAY_LOG(DEBUG) << "Deleting tasks, job id = " << job_id
|
||||
<< ", task id list size = " << task_ids.size();
|
||||
auto on_done = [job_id, task_ids, request, reply, send_reply_callback](Status status) {
|
||||
if (!status.ok()) {
|
||||
RAY_LOG(ERROR) << "Failed to delete tasks, job id = " << job_id
|
||||
<< ", task id list size = " << task_ids.size();
|
||||
}
|
||||
GCS_RPC_SEND_REPLY(send_reply_callback, reply, status);
|
||||
};
|
||||
|
||||
Status status = gcs_table_storage_->TaskTable().BatchDelete(task_ids, on_done);
|
||||
if (!status.ok()) {
|
||||
on_done(status);
|
||||
}
|
||||
RAY_LOG(DEBUG) << "Finished deleting tasks, job id = " << job_id
|
||||
<< ", task id list size = " << task_ids.size();
|
||||
++counts_[CountType::DELETE_TASKS_REQUEST];
|
||||
}
|
||||
|
||||
void DefaultTaskInfoHandler::HandleAddTaskLease(const AddTaskLeaseRequest &request,
|
||||
AddTaskLeaseReply *reply,
|
||||
SendReplyCallback send_reply_callback) {
|
||||
@@ -183,7 +159,6 @@ std::string DefaultTaskInfoHandler::DebugString() const {
|
||||
stream << "DefaultTaskInfoHandler: {AddTask request count: "
|
||||
<< counts_[CountType::ADD_TASK_REQUEST]
|
||||
<< ", GetTask request count: " << counts_[CountType::GET_TASK_REQUEST]
|
||||
<< ", DeleteTasks request count: " << counts_[CountType::DELETE_TASKS_REQUEST]
|
||||
<< ", AddTaskLease request count: " << counts_[CountType::ADD_TASK_LEASE_REQUEST]
|
||||
<< ", GetTaskLease request count: " << counts_[CountType::GET_TASK_LEASE_REQUEST]
|
||||
<< ", AttemptTaskReconstruction request count: "
|
||||
|
||||
@@ -35,9 +35,6 @@ class DefaultTaskInfoHandler : public rpc::TaskInfoHandler {
|
||||
void HandleGetTask(const GetTaskRequest &request, GetTaskReply *reply,
|
||||
SendReplyCallback send_reply_callback) override;
|
||||
|
||||
void HandleDeleteTasks(const DeleteTasksRequest &request, DeleteTasksReply *reply,
|
||||
SendReplyCallback send_reply_callback) override;
|
||||
|
||||
void HandleAddTaskLease(const AddTaskLeaseRequest &request, AddTaskLeaseReply *reply,
|
||||
SendReplyCallback send_reply_callback) override;
|
||||
|
||||
@@ -58,7 +55,6 @@ class DefaultTaskInfoHandler : public rpc::TaskInfoHandler {
|
||||
enum CountType {
|
||||
ADD_TASK_REQUEST = 0,
|
||||
GET_TASK_REQUEST = 1,
|
||||
DELETE_TASKS_REQUEST = 2,
|
||||
ADD_TASK_LEASE_REQUEST = 3,
|
||||
GET_TASK_LEASE_REQUEST = 4,
|
||||
ATTEMPT_TASK_RECONSTRUCTION_REQUEST = 5,
|
||||
|
||||
@@ -280,16 +280,6 @@ class GcsServerTest : public ::testing::Test {
|
||||
return task_data;
|
||||
}
|
||||
|
||||
bool DeleteTasks(const rpc::DeleteTasksRequest &request) {
|
||||
std::promise<bool> promise;
|
||||
client_->DeleteTasks(
|
||||
request, [&promise](const Status &status, const rpc::DeleteTasksReply &reply) {
|
||||
RAY_CHECK_OK(status);
|
||||
promise.set_value(true);
|
||||
});
|
||||
return WaitReady(promise.get_future(), timeout_ms_);
|
||||
}
|
||||
|
||||
bool AddTaskLease(const rpc::AddTaskLeaseRequest &request) {
|
||||
std::promise<bool> promise;
|
||||
client_->AddTaskLease(
|
||||
@@ -574,13 +564,6 @@ TEST_F(GcsServerTest, TestTaskInfo) {
|
||||
rpc::TaskTableData result = GetTask(task_id.Binary());
|
||||
ASSERT_TRUE(result.task().task_spec().job_id() == job_id.Binary());
|
||||
|
||||
// Delete task
|
||||
rpc::DeleteTasksRequest delete_tasks_request;
|
||||
delete_tasks_request.add_task_id_list(task_id.Binary());
|
||||
ASSERT_TRUE(DeleteTasks(delete_tasks_request));
|
||||
result = GetTask(task_id.Binary());
|
||||
ASSERT_TRUE(!result.has_task());
|
||||
|
||||
// Add task lease
|
||||
NodeID node_id = NodeID::FromRandom();
|
||||
auto task_lease_data = Mocker::GenTaskLeaseData(task_id.Binary(), node_id.Binary());
|
||||
|
||||
@@ -247,19 +247,6 @@ Status RedisTaskInfoAccessor::AsyncGet(
|
||||
return task_table.Lookup(task_id.JobId(), task_id, on_success, on_failure);
|
||||
}
|
||||
|
||||
Status RedisTaskInfoAccessor::AsyncDelete(const std::vector<TaskID> &task_ids,
|
||||
const StatusCallback &callback) {
|
||||
raylet::TaskTable &task_table = client_impl_->raylet_task_table();
|
||||
JobID job_id = task_ids.empty() ? JobID::Nil() : task_ids[0].JobId();
|
||||
task_table.Delete(job_id, task_ids);
|
||||
if (callback) {
|
||||
callback(Status::OK());
|
||||
}
|
||||
// TODO(micafan) Always return OK here.
|
||||
// Confirm if we need to handle the deletion failure and how to handle it.
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status RedisTaskInfoAccessor::AsyncSubscribe(
|
||||
const TaskID &task_id, const SubscribeCallback<TaskID, TaskTableData> &subscribe,
|
||||
const StatusCallback &done) {
|
||||
|
||||
@@ -182,9 +182,6 @@ class RedisTaskInfoAccessor : public TaskInfoAccessor {
|
||||
Status AsyncGet(const TaskID &task_id,
|
||||
const OptionalItemCallback<TaskTableData> &callback) override;
|
||||
|
||||
Status AsyncDelete(const std::vector<TaskID> &task_ids,
|
||||
const StatusCallback &callback) override;
|
||||
|
||||
Status AsyncSubscribe(const TaskID &task_id,
|
||||
const SubscribeCallback<TaskID, TaskTableData> &subscribe,
|
||||
const StatusCallback &done) override;
|
||||
|
||||
@@ -348,14 +348,6 @@ message GetTaskReply {
|
||||
TaskTableData task_data = 2;
|
||||
}
|
||||
|
||||
message DeleteTasksRequest {
|
||||
repeated bytes task_id_list = 1;
|
||||
}
|
||||
|
||||
message DeleteTasksReply {
|
||||
GcsStatus status = 1;
|
||||
}
|
||||
|
||||
message AddTaskLeaseRequest {
|
||||
TaskLeaseData task_lease_data = 1;
|
||||
}
|
||||
@@ -387,8 +379,6 @@ service TaskInfoGcsService {
|
||||
rpc AddTask(AddTaskRequest) returns (AddTaskReply);
|
||||
// Get task information from GCS Service.
|
||||
rpc GetTask(GetTaskRequest) returns (GetTaskReply);
|
||||
// Delete tasks from GCS Service.
|
||||
rpc DeleteTasks(DeleteTasksRequest) returns (DeleteTasksReply);
|
||||
// Add a task lease to GCS Service.
|
||||
rpc AddTaskLease(AddTaskLeaseRequest) returns (AddTaskLeaseReply);
|
||||
// Get task lease information from GCS Service.
|
||||
|
||||
@@ -249,8 +249,6 @@ table FreeObjectsRequest {
|
||||
// Whether keep this request with local object store
|
||||
// or send it to all the object stores.
|
||||
local_only: bool;
|
||||
// Whether also delete objects' creating tasks from GCS.
|
||||
delete_creating_tasks: bool;
|
||||
// List of object ids we'll delete from object store.
|
||||
object_ids: [string];
|
||||
}
|
||||
|
||||
@@ -1224,14 +1224,6 @@ void NodeManager::ProcessClientMessage(const std::shared_ptr<ClientConnection> &
|
||||
std::vector<ObjectID> object_ids = from_flatbuf<ObjectID>(*message->object_ids());
|
||||
// Clean up objects from the object store.
|
||||
object_manager_.FreeObjects(object_ids, message->local_only());
|
||||
if (message->delete_creating_tasks()) {
|
||||
// Clean up their creating tasks from GCS.
|
||||
std::vector<TaskID> creating_task_ids;
|
||||
for (const auto &object_id : object_ids) {
|
||||
creating_task_ids.push_back(object_id.TaskId());
|
||||
}
|
||||
RAY_CHECK_OK(gcs_client_->Tasks().AsyncDelete(creating_task_ids, nullptr));
|
||||
}
|
||||
} break;
|
||||
case protocol::MessageType::SubscribePlasmaReady: {
|
||||
ProcessSubscribePlasmaReady(client, message_data);
|
||||
|
||||
@@ -274,10 +274,10 @@ Status raylet::RayletClient::PushProfileEvents(const ProfileTableData &profile_e
|
||||
}
|
||||
|
||||
Status raylet::RayletClient::FreeObjects(const std::vector<ObjectID> &object_ids,
|
||||
bool local_only, bool delete_creating_tasks) {
|
||||
bool local_only) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto message = protocol::CreateFreeObjectsRequest(
|
||||
fbb, local_only, delete_creating_tasks, to_flatbuf(fbb, object_ids));
|
||||
auto message =
|
||||
protocol::CreateFreeObjectsRequest(fbb, local_only, to_flatbuf(fbb, object_ids));
|
||||
fbb.Finish(message);
|
||||
return conn_->WriteMessage(MessageType::FreeObjectsInObjectStoreRequest, &fbb);
|
||||
}
|
||||
|
||||
@@ -313,10 +313,8 @@ class RayletClient : public RayletClientInterface {
|
||||
/// \param object_ids A list of ObjectsIDs to be deleted.
|
||||
/// \param local_only Whether keep this request with local object store
|
||||
/// or send it to all the object stores.
|
||||
/// \param delete_creating_tasks Whether also delete objects' creating tasks from GCS.
|
||||
/// \return ray::Status.
|
||||
ray::Status FreeObjects(const std::vector<ray::ObjectID> &object_ids, bool local_only,
|
||||
bool deleteCreatingTasks);
|
||||
ray::Status FreeObjects(const std::vector<ray::ObjectID> &object_ids, bool local_only);
|
||||
|
||||
/// Sets a resource with the specified capacity and client id
|
||||
/// \param resource_name Name of the resource to be set
|
||||
|
||||
@@ -219,9 +219,6 @@ class GcsRpcClient {
|
||||
/// Get task information from GCS Service.
|
||||
VOID_GCS_RPC_CLIENT_METHOD(TaskInfoGcsService, GetTask, task_info_grpc_client_, )
|
||||
|
||||
/// Delete tasks from GCS Service.
|
||||
VOID_GCS_RPC_CLIENT_METHOD(TaskInfoGcsService, DeleteTasks, task_info_grpc_client_, )
|
||||
|
||||
/// Add a task lease to GCS Service.
|
||||
VOID_GCS_RPC_CLIENT_METHOD(TaskInfoGcsService, AddTaskLease, task_info_grpc_client_, )
|
||||
|
||||
|
||||
@@ -375,10 +375,6 @@ class TaskInfoGcsServiceHandler {
|
||||
virtual void HandleGetTask(const GetTaskRequest &request, GetTaskReply *reply,
|
||||
SendReplyCallback send_reply_callback) = 0;
|
||||
|
||||
virtual void HandleDeleteTasks(const DeleteTasksRequest &request,
|
||||
DeleteTasksReply *reply,
|
||||
SendReplyCallback send_reply_callback) = 0;
|
||||
|
||||
virtual void HandleAddTaskLease(const AddTaskLeaseRequest &request,
|
||||
AddTaskLeaseReply *reply,
|
||||
SendReplyCallback send_reply_callback) = 0;
|
||||
@@ -410,7 +406,6 @@ class TaskInfoGrpcService : public GrpcService {
|
||||
std::vector<std::unique_ptr<ServerCallFactory>> *server_call_factories) override {
|
||||
TASK_INFO_SERVICE_RPC_HANDLER(AddTask);
|
||||
TASK_INFO_SERVICE_RPC_HANDLER(GetTask);
|
||||
TASK_INFO_SERVICE_RPC_HANDLER(DeleteTasks);
|
||||
TASK_INFO_SERVICE_RPC_HANDLER(AddTaskLease);
|
||||
TASK_INFO_SERVICE_RPC_HANDLER(GetTaskLease);
|
||||
TASK_INFO_SERVICE_RPC_HANDLER(AttemptTaskReconstruction);
|
||||
|
||||
Reference in New Issue
Block a user