You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "keith-turner (via GitHub)" <gi...@apache.org> on 2025/03/18 20:58:12 UTC
[PR] removes root path from lock id serialization [accumulo]
keith-turner opened a new pull request, #5417:
URL: https://github.com/apache/accumulo/pull/5417
In order to make this change needed to analyze how the code uses LockId, based on this anylsis ended up making a few changes.
Some code was caching the serialized form of the lock id and keeping a string around. Its better to keep the lock id type around instead of a string, so made lock id memoize serialization to support doing this.
The lock id constructor was removing extraneous slashes at the end of the lock path. However it seemed this would never happen in the code. Removed this handling and instead added a check that paths do not end w/ a slash. Also added some other validation in the constructor. Noticed this object is created alot in the manager and tablet server, to avoid the repeated validation made ServiceLock cache the LockId instead of always creating it.
fixes #5410
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] removes root path from lock id serialization [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner merged PR #5417:
URL: https://github.com/apache/accumulo/pull/5417
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] removes root path from lock id serialization [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #5417:
URL: https://github.com/apache/accumulo/pull/5417#discussion_r2003573464
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ConditionalWriterImpl.java:
##########
@@ -683,7 +682,7 @@ private void invalidateSession(SessionID sessionId, HostAndPort location)
long startTime = System.currentTimeMillis();
- LockID lid = new LockID(Constants.ZTSERVERS, sessionId.lockId);
+ LockID lid = LockID.deserialize(sessionId.lockId);
Review Comment:
This code was only used by the conditional writer client side in failure cases. The server side would substract the tservers prefix and client would add it back to check if tserver was still alive. This particular case was really dangerous on the tserver side because it was a tserver instance variable w/ different prefix behavior than all other lock checking code, so if anything else used this tserver variable it could have easily gotten it wrong. On the tserver side it uses a LockId var instead of a string now for the instance variable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] removes root path from lock id serialization [accumulo]
Posted by "kevinrr888 (via GitHub)" <gi...@apache.org>.
kevinrr888 commented on PR #5417:
URL: https://github.com/apache/accumulo/pull/5417#issuecomment-2741325580
Just saw this this is a lot nicer. Was very confusing working with LockID before...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] removes root path from lock id serialization [accumulo]
Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #5417:
URL: https://github.com/apache/accumulo/pull/5417#discussion_r2002145459
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ConditionalWriterImpl.java:
##########
@@ -683,7 +682,7 @@ private void invalidateSession(SessionID sessionId, HostAndPort location)
long startTime = System.currentTimeMillis();
- LockID lid = new LockID(Constants.ZTSERVERS, sessionId.lockId);
+ LockID lid = LockID.deserialize(sessionId.lockId);
Review Comment:
Do you know why this one had the `/tservers` part in there? I couldn't figure out why that was there, even before the chroot changes.
##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooUtil.java:
##########
@@ -67,33 +71,48 @@ public static class LockID {
public final long eid;
public final String path;
public final String node;
+ private final Supplier<String> serialized;
+
+ public LockID(String path, String node, long eid) {
+ // Do not allow the path to end with / because this would cause problems for serialization. Do
+ // not allow $ char in path as this would cause problems for serialization. Current code does
+ // not pass these as input. The path is expected to be an absolute path, so check it starts
+ // with /.
+ Preconditions.checkArgument(
+ path != null && !path.contains("$") && path.startsWith("/") && !path.endsWith("/"),
+ "Illegal path %s", path);
+ // Do not allow $ and / chars in the node name as this would cause problems for serialization.
+ // Current code does not pass these as input.
Review Comment:
```suggestion
// node must not contain '$' or '/'
```
##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooUtil.java:
##########
@@ -67,33 +71,48 @@ public static class LockID {
public final long eid;
public final String path;
public final String node;
+ private final Supplier<String> serialized;
+
+ public LockID(String path, String node, long eid) {
+ // Do not allow the path to end with / because this would cause problems for serialization. Do
+ // not allow $ char in path as this would cause problems for serialization. Current code does
+ // not pass these as input. The path is expected to be an absolute path, so check it starts
+ // with /.
Review Comment:
The constraint on the path could be made more succinct:
```suggestion
// path must start with a '/', must not end with one, and must not contain '$'.
```
##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooUtil.java:
##########
@@ -67,33 +71,48 @@ public static class LockID {
public final long eid;
public final String path;
public final String node;
+ private final Supplier<String> serialized;
+
+ public LockID(String path, String node, long eid) {
+ // Do not allow the path to end with / because this would cause problems for serialization. Do
+ // not allow $ char in path as this would cause problems for serialization. Current code does
+ // not pass these as input. The path is expected to be an absolute path, so check it starts
+ // with /.
+ Preconditions.checkArgument(
+ path != null && !path.contains("$") && path.startsWith("/") && !path.endsWith("/"),
+ "Illegal path %s", path);
Review Comment:
I did not know you could use format strings with Preconditions!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org