Giter VIP home page Giter VIP logo

ngx-distributed-shm's People

Contributors

actions-user avatar alexist avatar cristichiru avatar dependabot[bot] avatar gregoire-rolland-cbp avatar grrolland avatar sgandon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ngx-distributed-shm's Issues

the lua script does not respect the dshm protocol

when calling the "set" command twice with the lua script we have an issue with a ERROR malformed_request that is returned by the dshm server.
Here is a dump of the buffer received by the protocol handler

buffer:set sessions::ZWH6NJT2o6hYROBZqaS1eA 3600 22
buffer:tpHMMfyybPjneoCl30YYyQ
buffer:
buffer:set sessions::ZWH6NJT2o6hYROBZqaS1eA 3600 192
buffer:V0ckHpTdetg42-cKciJHjGBAcomwZcrpYfV71e-z4f49PfHZJnDAatMnPh-Ud2I4e8JA0TGv_DfkTLrTULiqdt8aIzcB_PmPHI0f2xp0JvTSY7PKbglLf0pqmyqVZbCqs3dDO-br4Xp03LwoWl8V_ZHMzguMRoDaEmvj7rBvjblbRcj--5Dden6_FfDUolhY
buffer:

You can see there is a call to the handle with an empty buffer when setting a value and this call will generate an ERROR malformed_request string on the socket.
The reason for this is that the lua script does not respect the protocol and adds an \r\n at the end of the value, see here. But the protocol is switching to fixedSizeMode thus making the last \r\n part of the next buffer handling.
The fix is simple and is working for us that is removing this line and I'll propose a PR soon.

IncrProcessor executed on each backup

Hi,

When deployed in a cluster with backup-count greater than 0, IncrCommand is executed on each backup. For example, with 1 backup;

INCR KEY 1 1
LEN 1
1
DONE
GET KEY
LEN 1
3
DONE

The issue is related to this line in IncrCommand :

map.set(entry.getKey(), new ShmValue(newval, expire), expire, TimeUnit.SECONDS);

This code fix the issue :

ExtendedMapEntry<String, ShmValue> extendedMapEntry = (ExtendedMapEntry<String, ShmValue>) entry
extendedMapEntry.setValue(new ShmValue(newval, expire), expire, TimeUnit.SECONDS);

This is documented in Javadoc :
The entry's value will be null, if the entry for the key doesn't exist. You can create new mapping by setting a non-null value or remove existing mapping entry by setting the value to null.

telnet error

Hi,

When testing SET command with telnet, i get an malformed_request

SET KEY 0 1
1
LEN 1
1
DONE
ERROR malformed_request

In unit test, we don't have the malformed_request, because "\r\n" is not send

getWriter().write("SET region:key 1 10\r\n");
getWriter().write("1234567890");
getWriter().flush();

Maybe there is a way to send the command without carriage return in telnet ?

Otherwhise, this issue can be fixed in two ways

  1. Setting an expectedMode to FrameMode.END
 else if (expectedMode == FrameMode.DATA) {
       final String result = currentCommand.executeDataPart(buffer.toString(PROTOCOL_ENCODING));
       socket.write(result, PROTOCOL_ENCODING);
       expectedMode = FrameMode.END;
       parser.delimitedMode(PROTOCOL_DELIMITER);
  }
  else {
        expectedMode = FrameMode.COMMAND;
   }

but this will make a breaking change

  1. Handling empty command in ShmProtocolHandler.handle :
    if (expectedMode == FrameMode.COMMAND && !buffer.toString(PROTOCOL_ENCODING).isEmpty()) {
    }
    but not sure allowing empty command is a good idea

Memory consumption and probes

Hello,
We are thinking of using dshm with openresty in order to cache our web app sessions among multiple instances in a Kubernetes environment.
You provide some Kubernetes manifest example which is nice but in terms of production readyness I was wondering if you could provide some guidance in the RAM requirements for the container (Requests and limits).
I would also like to ask if it is possible to setup some kind of readyness and liveness probe as well ?

INCR with initial TTL

Hi,

The lua.shared semantic has evolved. The method incr now accept an optional parameter init_ttl :

syntax: newval, err, forcible? = ngx.shared.DICT:incr(key, value, init?, init_ttl?)

init_ttl allow to create the missing key with a ttl and avoid to make another call to handle expiration (incr than expire)

remaining, err = dict:incr(key, -1, limit, window)

I can submit a PR to add this new optional parameter in ngx-distributed-shm

Kubernetes pod does not finish when term signal is sent

Hello,
We have deactivated the stopping of the sig term in this PR. And now the signal reaches the JVM and hazelcast performs a gracefull shutdown.
But the process does not end and the pod remains running until K8s timesout and kills the container.
That would be nice to have a proper end of container and will make the updates faster in K8s.
I did not find a way to fix this :(

INCR : expiration issue

Hi,

There is an issue with the IncrCommand and deadline/getLastingTime() calculation.

The problem is related to a double to int conversion.

Each time a key is incremented, the delay will decreases faster than time passes due to the conversion

With 200 command

SET KEY 60 4
1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
INCR KEY 1 1000
....

The output will look like :

...
1091
DONE
LEN 4
1092
DONE
LEN 4
1001
DONE
LEN 4
1002
DONE
LEN 4
1003

Hazelcast has a method setValueWithoutChangingExpiryTime that can be used instead of managing the lasting time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.