Comments (14)
The provided ttl should not be a timestamp - we could extend the API to be more explicit, like adding .set(key, value, instant)
or .set(key, value, duration)
from folsom.
Partially solved in release 1.3.0.
from folsom.
Thanks for the report! I will look into it.
from folsom.
To clarify - what kind of error do you see? Are entries expiring too late or too early?
from folsom.
Entries not expiring at all - or maybe way too late for my tests to identify. My test just sets a key with a TTL, and expects a GET to that key to return null
after the TTL passes (plus a substantial margin).
BTW I'm reproducing with pure folsom code also:
public class FolsomExpirationTest {
private MemcacheClient<byte[]> memcacheClient;
@Before
public void setUp() throws Exception {
memcacheClient = MemcacheClientBuilder.newByteArrayClient().withAddress("127.0.0.1").connectBinary();
ConnectFuture.connectFuture(memcacheClient).toCompletableFuture().get(30, TimeUnit.SECONDS);
}
@After
public void tearDown() {
memcacheClient.shutdown();
}
@Test
public void textExpiration() {
int ttl = 5;
String key = randomKey();
byte[] value = randomValue();
memcacheClient.set(key, value, ttl).toCompletableFuture().join();
await().atMost(ttl * 2, TimeUnit.SECONDS)
.untilAsserted(() -> assertNull(memcacheClient.get(key).toCompletableFuture().join()));
}
private static byte[] randomValue() {
byte[] b = new byte[5];
new Random().nextBytes(b);
return b;
}
private static String randomKey() {
return UUID.randomUUID().toString();
}
}
changing connection to connectAscii
makes test pass, whereas connectBinary
fails consistently here.
from folsom.
Passing consistently on:
- Ubuntu 18.04, Oracle JDK 1.8.0_201, Memcached 1.5.6
- OS X 10.14.2, Oracle JDK 1.8.0_66 (Laptop 2), Memcached 1.5.8 and 1.5.12
Failing consistently on:
- OS X 10.14.2, Oracle JDK 1.8.0_181 (Laptop 1), Memcached 1.5.12
Randomly failing/passing on:
- AWS Linux 4.14.77-70.82.amzn1.x86_64, Oracle JDK 1.8.0_162, Memcached 1.4.15
from folsom.
I could reproduce it by changing the memcached version, see:
#113
It looks more like a regression in memcached itself than a problem in folsom.
from folsom.
I see. It's possible, but it seems to fail too in 1.4.15 randomly... that's why we initially discarded memcache version (1.4.15+Linux failing sometimes, 1.5.6+Linux passing, 1.5.12+Mac failing).
from folsom.
Testing with more versions of memcached, it seems to depend more on type of image than version. Fails on ol-7 but works on debian / regular builds.
According to specification:
Some commands involve a client sending some kind of expiration time
(relative to an item or to an operation requested by the client) to
the server. In all such cases, the actual value sent may either be
Unix time (number of seconds since January 1, 1970, as a 32-bit
value), or a number of seconds starting from current time. In the
latter case, this number of seconds may not exceed 60*60*24*30 (number
of seconds in 30 days); if the number sent by a client is larger than
that, the server will consider it to be real Unix time value rather
than an offset from current time.
A workaround from our side could be to always send it as a unix timestamp if possible (carefully trying to avoid the year 2038 problem)
from folsom.
I see. Thanks for the input. I'll move all my code to use timestamps instead.
from folsom.
Actually in the binary version of the SetRequest
command, this is done:
public ByteBuf writeRequest(final ByteBufAllocator alloc, final ByteBuffer dst) {
final int expiration = Utils.ttlToExpiration(ttl);
so timestamps are already in-use...
BTW I'm not sure this code is correct either:
public static int ttlToExpiration(final int ttl) {
return (ttl == 0) ? 0 : (int) (System.currentTimeMillis() / 1000) + ttl;
}
as it doesn't take into account if the provided "ttl" is already a timestamp.
(ASCII version uses TTL as-is, whereas binary enforces passing of TTL. I think the ttlToExpiration should check if the provided ttl is already above 606024*30 before doing that operation)
from folsom.
With ASCII and timestamps obtained thru Utils.tottlToExpiration
it also fails...
from folsom.
Good catch! I'll take a look at that.
from folsom.
Does this change make sense to start with? Do you think it would solve your issues?
#114
from folsom.
Related Issues (20)
- file descriptor leak HOT 3
- Configurable number of connections to memcached server HOT 2
- ReconnectingClient prints "Lost connection" for old nodes when another one is added - while requests go through just fine HOT 4
- Remove or shade/hide guava dependency HOT 4
- Reusable buffers as parameter for getters HOT 1
- Support for incr/decr commands HOT 1
- let's add docs how to run build and tests locally? (Docker container) HOT 1
- Add tracing HOT 2
- Feature request: per node telemetry
- Exceptions with java 11 HOT 1
- Add Micrometer metrics HOT 3
- Folsom - Spring Boot DevTools class loader HOT 3
- Release notes or CHANGELOG HOT 1
- Extending MemcacheClientBuilder to more easily allow other AbstractMultiMemcacheClient impl HOT 2
- Folsom
- Introduce OpenTelemetry metrics and tracing HOT 3
- Last 2 versions were not released HOT 1
- Client failure after responding to too many requests where value is too large HOT 2
- How can I connect a sasl memcached server via folsom HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from folsom.