Repository navigation
Make netty 4.0 attributes definition compatible with Apache Atlas 1.1.0 - #906
Conversation
The issue we are trying to fix here seems to be a result of two concurrent issues.
Cassandra driver's used by atlas 1.1.0 brings in a old version of netty < 4.0.23.
In version 4.0.25 netty raised exception in `UniqueName` class for duplicate name
```
if (map.putIfAbsent(name, Boolean.TRUE) != null) {
throw new IllegalArgumentException(String.format("'%s' is already in use", name));
}
```
This changed in 4.0.26 where exception was not thrown, instead the duplicate key was just ignored.
```
protected UniqueName(String name) {
this.name = checkNotNull(name, "name");
id = nextId.incrementAndGet();
}
```
Now this alone would not be enough. The only way I was able to reproduce is if two different class loaders tries to load the
same class `AttributeKeys` twice.
I tried to look into Atlas source code (which is huge) and I could not find a clear path of how this would be possible.
Further more, looking at some build scripts that a user experiencing this issue provided,
it looks like they are doing everything correctly and there is nothing they should change.
In conclusion, I believe that even if this is not a very clean approach,
we should be resilient to this use case, when a customer using netty <4.0.25 in an
older version of Apache Atlas (or with some sort of class loader behavior).
be8bf24 to
bfa5712
Compare
… in the world until it works'
tylerbenson
left a comment
There was a problem hiding this comment.
Couple of small things... Consider adding the double-check locking.
| @Override | ||
| public V getOrCreate(K key, ValueSupplier<V> supplier) { | ||
| if (!map.containsKey(key)) { | ||
| map.put(key, supplier.get()); |
There was a problem hiding this comment.
Consider adding "double check locking" here to ensure thread safety.
| * prevents an issue with Apache Atlas project were this class loaded by multiple class loaders, | ||
| * while the Attribute class is loaded by a third class loader and used internally for the | ||
| * cassandra driver. | ||
| */ |
There was a problem hiding this comment.
Do we want/need a similar change in the netty 4.0 instrumentation?
There was a problem hiding this comment.
I think you are referring to 4.1. I think this issue is very specific to the usage that Apache Atlas does of the class loaders + netty. We can do that as a safety net though, as I do not see any disadvantage, so good call.
| def "getOrCreate a value"() { | ||
| setup: | ||
| def supplier = new CounterSupplier() | ||
| def sut = new WeakMap.MapAdapter<String, Integer>(new WeakHashMap<>()) |
There was a problem hiding this comment.
These could be moved to class fields instead of having to duplicate for each test. (Unless marked as @Shared, Spock will reinitialize before each test.)
| @Override | ||
| public synchronized V getOrCreate(K key, ValueSupplier<V> supplier) { | ||
| if (!map.containsKey(key)) { | ||
| map.put(key, supplier.get()); |
There was a problem hiding this comment.
Trade synchronized for double check locking here instead.
|
Looks like there's a conflict with master and the tests are failing. Once those are fixed, good to merge. |
…i/atlas-1.1.0-compatibility
|
Merge conflict resolved and added new style definition for new property in |
The issue we are trying to fix here seems to be a result of two concurrent issues.
Cassandra driver's used by atlas 1.1.0 brings in a old version of netty < 4.0.23.
In version 4.0.25 netty raised exception in
UniqueNameclass for duplicate nameThis changed in 4.0.26 where exception was not thrown, instead the duplicate key was just ignored.
Now this alone would not be enough. The only way I was able to reproduce is if two different class loaders tries to load the
same class
AttributeKeystwice.I tried to look into Atlas source code (which is huge) and I could not find a clear path of how this would be possible.
Further more, looking at some build scripts that a user experiencing this issue provided,
it looks like they are doing everything correctly and there is nothing they should change.
In conclusion, I believe that even if this is not a very clean approach,
we should be resilient to this use case, when a customer using netty <4.0.25 in an
older version of Apache Atlas (or with some sort of class loader behavior).