Skip to content

Commit 51459db

Browse files
feat: micro fix
1 parent eb6106c commit 51459db

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

shedlock-ydb/src/main/java/tech/ydb/lock/provider/YdbCoordinationServiceLockProvider.java

-26
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.sql.SQLException;
55
import java.time.Instant;
66
import java.util.Optional;
7-
import javax.annotation.PostConstruct;
87
import javax.annotation.PreDestroy;
98
import net.javacrumbs.shedlock.core.LockConfiguration;
109
import net.javacrumbs.shedlock.core.LockProvider;
@@ -15,7 +14,6 @@
1514
import tech.ydb.coordination.CoordinationClient;
1615
import tech.ydb.coordination.CoordinationSession;
1716
import tech.ydb.coordination.SemaphoreLease;
18-
import tech.ydb.coordination.settings.DescribeSemaphoreMode;
1917
import tech.ydb.core.Result;
2018
import tech.ydb.jdbc.YdbConnection;
2119

@@ -37,7 +35,6 @@ public YdbCoordinationServiceLockProvider(YdbConnection ydbConnection) {
3735
this.coordinationClient = CoordinationClient.newClient(ydbConnection.getCtx().getGrpcTransport());
3836
}
3937

40-
@PostConstruct
4138
public void init() {
4239
for (int i = 0; i < ATTEMPT_CREATE_NODE; i++) {
4340
var status = coordinationClient.createNode(YDB_LOCK_NODE_NAME).join();
@@ -73,29 +70,6 @@ public Optional<SimpleLock> lock(LockConfiguration lockConfiguration) {
7370

7471
logger.info("Instance[{}] is trying to become a leader...", instanceInfo);
7572

76-
var describeResult = coordinationSession.describeSemaphore(
77-
lockConfiguration.getName(),
78-
DescribeSemaphoreMode.WITH_OWNERS
79-
).join();
80-
81-
if (describeResult.isSuccess()) {
82-
var describe = describeResult.getValue();
83-
var describePayload = new String(describe.getData(), StandardCharsets.UTF_8);
84-
85-
logger.debug("Received DescribeSemaphore[Name={}, Data={}]", describe.getName(), describePayload);
86-
87-
Instant createdLeaderTimestampUTC = Instant.parse(describePayload.split(",")[2].split("=")[1]);
88-
89-
if (now.isAfter(createdLeaderTimestampUTC.plus(lockConfiguration.getLockAtMostFor()))) {
90-
var deleteResult = coordinationSession.deleteSemaphore(describe.getName(), true).join();
91-
logger.debug("Delete semaphore[Name={}] result: {}", describe.getName(), deleteResult);
92-
}
93-
} else {
94-
// no success, ephemeral semaphore is not created
95-
96-
logger.debug("Semaphore[Name={}] not found", lockConfiguration.getName());
97-
}
98-
9973
Result<SemaphoreLease> semaphoreLease = coordinationSession.acquireEphemeralSemaphore(
10074
lockConfiguration.getName(),
10175
true,

0 commit comments

Comments
 (0)