Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache breaks compatibility #2821

Open
kodebach opened this issue Jul 12, 2019 · 3 comments

Comments

@kodebach
Copy link
Contributor

commented Jul 12, 2019

I'm not sure whether this one can be solved, but I think the cache currently breaks backwards compatibility.

While working on #2809 I tried to add a test case that does the following:

  1. Compile all the libs (i.e. all the *.so.0.8.26 files in $BUILD_DIR/lib)
  2. Download the latest release from https://www.libelektra.org/ftp/elektra/releases
  3. Extract and build this release
  4. Copy the libs compiled in step 1 into the build directory of step 3
  5. Run the tests of the latest release

A lot of the test cases fail, becaue libelektra-cache.so cannot be found.

Compiling with -DPLUGINS="ALL;-EXPERIMENTAL;-cache" in step 1 solves the problem, so it is definitely the cache that is at fault here.


Here is the script I used for testing (it is not a proper test case yet):

#!/bin/bash

RELEASE="0.8.26"

SCRIPTS_DIR=$(dirname "$0")
SOURCE_DIR="$SCRIPTS_DIR/.."

BASE_DIR=$(mktemp -d)
BUILD_DIR="$BASE_DIR/build"

RELEASE_SOURCE_DIR="$BASE_DIR/release"
RELEASE_BUILD_DIR="$BASE_DIR/release/build"

DEFAULT_CMAKE_OPT+=(
      -DKDB_DB_SYSTEM="$RELEASE_BUILD_DIR/kdb/system"
      -DKDB_DB_SPEC="$RELEASE_BUILD_DIR/kdb/spec"
      -DKDB_DB_HOME="$RELEASE_BUILD_DIR/kdb/home"
    )

CMAKE_OPTS=${CMAKE_OPTS:-${DEFAULT_CMAKE_OPT[@]}}

OLD_DIR=$(pwd)

trap 'exit $?' ERR
-DKDB_DB_SPEC="$RELEASE_BUILD_DIR/kdb/spec"
mkdir "$BUILD_DIR"

cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DENABLE_TESTING=OFF
LIBS=$(cmake -L -S "$SOURCE_DIR" -B "$BUILD_DIR" | grep -Fi "ADDED_LIBS" | cut -d '=' -f 2)
LIB_TARGETS=$(echo "$LIBS" | tr ';' ' ')

cd "$BUILD_DIR"
make ${LIB_TARGETS}
cd "$OLD_DIR"

curl "https://www.libelektra.org/ftp/elektra/releases/elektra-$RELEASE.tar.gz" --output "$BASE_DIR/release.tar.gz" --silent
tar -xzf "$BASE_DIR/release.tar.gz" -C "$BASE_DIR"
mv "$BASE_DIR/elektra-$RELEASE" "$BASE_DIR/release"

cmake -S "$RELEASE_SOURCE_DIR" -B "$RELEASE_BUILD_DIR" ${CMAKE_OPTS}
cd "$RELEASE_BUILD_DIR"
make

cp "$BUILD_DIR/lib/"*".$RELEASE" "$RELEASE_BUILD_DIR/lib/"

make -C "$RELEASE_BUILD_DIR" run_all
cd "$OLD_DIR"
@kodebach kodebach referenced this issue Jul 12, 2019
1 of 14 tasks complete
@mpranj

This comment has been minimized.

Copy link
Member

commented Jul 20, 2019

I'm pretty sure this is caused by how I detect that the cache is compiled.

// TODO: this is a poor way of detecting whether cache is compiled, but simply
// matching against cache might fail because of other plugins (e.g. "cachefilter")
if (strstr (ELEKTRA_PLUGINS, ";cache;") != NULL)
{
ksAppendKey (config, keyNew ("system/elektra/globalplugins/postgetcache", KEY_VALUE, "cache", KEY_END));
ksAppendKey (config, keyNew ("system/elektra/globalplugins/pregetcache", KEY_VALUE, "cache", KEY_END));
}

However, according to @markus2330 in the long run it should be default and always mounted, similar to list. It should work on all POSIX compliant systems. I think this can definitely be solved. A trivial solution would be to silently fail (simply not mount it) on non-POSIX systems.

@markus2330

This comment has been minimized.

Copy link
Contributor

commented Jul 31, 2019

Is this really a compatibility problem or some other issue? I cannot reproduce it. If I install "elektra-tests_0.8.26-1_amd64.deb" with libelektra from master, I do not see any warnings about the cache and kdb info cache works (there are many other problems, though: ini, yajl, reference, ... fail).

@kodebach thank you for the script. What is the difference between trap 'exit $?' ERR and set -e?

@mpranj yes, in general I am very open to make mmap to a fundamental part of Elektra. At the moment, however, it seems like it does not change the semantics anyway. If we can keep Elektra working also without mmap it would be nice (for constrained systems where the 50kB of the mmap plugin might be a problem).

So, as discussed in #2831, we can simply let mount.c succeed silently if the cache plugin was not found. Only after a user explicitly activated the cache, she should get a warning.

If we make the mmap cache a required part of Elektra, we should fail if the cache is not present (both in CMake and at run-time).

@kodebach

This comment has been minimized.

Copy link
Contributor Author

commented Jul 31, 2019

What is the difference between trap 'exit $?' ERR and set -e?

Not sure that would set -e preserves the exit code, but the actual reason why I used a trap is that I had additional debugging code instead of exit $? at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.