palantir / atlasdb

Transactional Distributed Database Layer
https://palantir.github.io/atlasdb/
Apache License 2.0
53 stars 9 forks source link

Fix duplicate key error in RetryableCassandraRequest #7085

Closed pkoenig10 closed 5 months ago

pkoenig10 commented 5 months ago

https://github.com/palantir/atlasdb/pull/6943 made the incorrect assumption that Cassandra server host names are unique.

We are seeing internal errors coming from AtlasDB in our internal authentication product.

java.lang.IllegalStateException: {throwable0_message}
    at one.util.streamex.AbstractStreamEx.addToMap(AbstractStreamEx.java:101)
    at one.util.streamex.EntryStream.lambda$toMapConsumer$1(EntryStream.java:95)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.concurrent.ConcurrentHashMap$EntrySpliterator.forEachRemaining(ConcurrentHashMap.java:3652)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
    at one.util.streamex.AbstractStreamEx.forEach(AbstractStreamEx.java:360)
    at one.util.streamex.EntryStream.toMap(EntryStream.java:1269)
    at com.palantir.atlasdb.keyvalue.cassandra.RetryableCassandraRequest.throwLimitReached(RetryableCassandraRequest.java:88)
    at com.palantir.atlasdb.keyvalue.cassandra.CassandraRequestExceptionHandler.logAndThrowException(CassandraRequestExceptionHandler.java:124)
    at com.palantir.atlasdb.keyvalue.cassandra.CassandraRequestExceptionHandler.handleExceptionFromRequest(CassandraRequestExceptionHandler.java:86)
    at com.palantir.atlasdb.keyvalue.cassandra.CassandraClientPoolImpl.runWithRetryOnServer(CassandraClientPoolImpl.java:622)
pkoenig10 commented 5 months ago

Yeah I did this because CassandraServer.toString will be some complex string, which didn't feel appropriate to use as a JSON property names in the logs. I'm not sure how well these will be rendered or how usable they will be in our log tooling.

It would be a bit cleaner to create an explicit RetriedHost struct here instead of (ab)using Map.Entry.

Let me know if you'd prefer that or if you'd prefer to just use the complex string as a map key.

svc-autorelease commented 5 months ago

Released 0.1075.0