This is an automated email from the ASF dual-hosted git repository.
dlmarion pushed a commit to branch elasticity
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/elasticity by this push:
new 0d72500bf2 Modified UserFateStore.create to behave like MetaFateStore
(#4787)
0d72500bf2 is described below
commit 0d72500bf2fa35916818e9d50b9956ab0950c686
Author: Dave Marion <[email protected]>
AuthorDate: Fri Aug 9 13:49:39 2024 -0400
Modified UserFateStore.create to behave like MetaFateStore (#4787)
MetaFateStore.create will retry forever when a collision happens
when trying to create a Fate transaction. The probabiliy of a
collision is low due to a random UUID being used. Before this change
the UserFateStore.create method would retry 5 times then throw an
exception. This was removed in favor of an unlimited retry so that
the behavior of the two Fate stores is the same.
Closes #4246
---
.../accumulo/core/fate/user/UserFateStore.java | 8 ++---
.../accumulo/test/fate/user/UserFateStoreIT.java | 36 ----------------------
2 files changed, 4 insertions(+), 40 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/fate/user/UserFateStore.java
b/core/src/main/java/org/apache/accumulo/core/fate/user/UserFateStore.java
index 75fdeca989..7fdcfd3aa0 100644
--- a/core/src/main/java/org/apache/accumulo/core/fate/user/UserFateStore.java
+++ b/core/src/main/java/org/apache/accumulo/core/fate/user/UserFateStore.java
@@ -88,9 +88,10 @@ public class UserFateStore<T> extends AbstractFateStore<T> {
@Override
public FateId create() {
- final int maxAttempts = 5;
- for (int attempt = 0; attempt < maxAttempts; attempt++) {
+ int attempt = 0;
+ while (true) {
+
FateId fateId = getFateId();
if (attempt >= 1) {
@@ -106,13 +107,12 @@ public class UserFateStore<T> extends
AbstractFateStore<T> {
return fateId;
case UNKNOWN:
case REJECTED:
+ attempt++;
continue;
default:
throw new IllegalStateException("Unknown status " + status);
}
}
-
- throw new IllegalStateException("Failed to create new id after " +
maxAttempts + " attempts");
}
public FateId getFateId() {
diff --git
a/test/src/main/java/org/apache/accumulo/test/fate/user/UserFateStoreIT.java
b/test/src/main/java/org/apache/accumulo/test/fate/user/UserFateStoreIT.java
index 337f9e4bdc..760fa87149 100644
--- a/test/src/main/java/org/apache/accumulo/test/fate/user/UserFateStoreIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/fate/user/UserFateStoreIT.java
@@ -24,11 +24,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
-import java.util.stream.Collectors;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.BatchWriter;
@@ -61,14 +59,11 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.collect.MoreCollectors;
public class UserFateStoreIT extends SharedMiniClusterBase {
- private static final Logger log =
LoggerFactory.getLogger(UserFateStore.class);
private static final FateInstanceType fateInstanceType =
FateInstanceType.USER;
@BeforeAll
@@ -150,37 +145,6 @@ public class UserFateStoreIT extends SharedMiniClusterBase
{
}
}
- @Test
- public void testCreateWithCollisionAndExceedRetryLimit() throws Exception {
- String table = getUniqueNames(1)[0];
- try (ClientContext client =
- (ClientContext) Accumulo.newClient().from(getClientProps()).build()) {
- createFateTable(client, table);
-
- UUID[] uuids = new UUID[5];
- for (int i = 0; i < uuids.length; i++) {
- uuids[i] = UUID.randomUUID();
- }
- List<UUID> txids =
- List.of(uuids[0], uuids[0], uuids[0], uuids[1], uuids[2], uuids[2],
uuids[2], uuids[2],
- uuids[3], uuids[3], uuids[4], uuids[4], uuids[4], uuids[4],
uuids[4], uuids[4]);
- List<FateId> fateIds = txids.stream().map(txid ->
FateId.from(fateInstanceType, txid))
- .collect(Collectors.toList());
- Set<FateId> expectedFateIds = new LinkedHashSet<>(fateIds);
- TestUserFateStore store = new TestUserFateStore(client, table, fateIds);
-
- // call create and expect we get the unique txids
- for (FateId expectedFateId : expectedFateIds) {
- FateId fateId = store.create();
- log.info("Created fate id: " + fateId);
- assertEquals(expectedFateId, fateId, "Expected " + expectedFateId + "
but got " + fateId);
- }
-
- // Calling create again on 5L should throw an exception since we've
exceeded the max retries
- assertThrows(IllegalStateException.class, store::create);
- }
- }
-
@Nested
class TestStatusEnforcement {