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

AEROSPIKE_ERR_RECORD_NOT_FOUND after refresh or redirect. #6

Closed
paulm17 opened this issue Aug 31, 2015 · 2 comments
Closed

AEROSPIKE_ERR_RECORD_NOT_FOUND after refresh or redirect. #6

paulm17 opened this issue Aug 31, 2015 · 2 comments

Comments

@paulm17
Copy link

paulm17 commented Aug 31, 2015

Hi,

I am having issues where I set a record and after I do a redirect or refresh, then I see in the logs:

Error 2 : AEROSPIKE_ERR_RECORD_NOT_FOUND : Array\n(\n    [ns] => sessions\n    [set] => session\n    [key] => session_9c7b3414346b04e489a88a25a4328b67\n)\n

My code for generating my own session:

public function set_click_session($session_data)
{
    $uniq_id = $this->gen_session_id();

    $as_data = array(
        'bin' => 'sessions',
        'table' => 'session',
        'key' => "session_" . $uniq_id
    );

    $this->aerospike_funcs->set($as_data, $session_data);
}

public function get_click_session()
{
    $uniq_id = $this->gen_session_id();

    $as_data = array(
        'bin' => 'sessions',
        'table' => 'session',
        'key' => "session_" . $uniq_id
    );

    return $this->aerospike_funcs->get($as_data);
}

private function gen_session_id()
{
    // Create unique id for decoding
    $id = ip2long($this->input_funcs->ip_address()) . '#' . $this->input_funcs->user_agent();
    $uniq_id = md5($id);

    return $uniq_id;
}

My code for the aerospike functionality:

<?php

class aerospike_funcs
{
    public function __construct()
    {
        $this->app = \Slim\Slim::getInstance();
        $this->db = $this->app->aerospike_db;
    }

    public function reset_id()
    {
        $id = $this->db->initKey('writes', 'sub_id', 'id');
        $this->db->remove($id);

        $id = $this->db->initKey('writes', 'click_id', 'id');
        $this->db->remove($id);
    }

    public function increment_id($type)
    {
        $key = $this->db->initKey('writes', $type, 'id');

        $op = [
            ['bin' => 'id', 'val' => 1, 'op' => Aerospike::OPERATOR_INCR],
            ['bin' => 'id', 'op' => Aerospike::OPERATOR_READ]];

        $status = $this->db->operate($key, $op, $r);

        if ($status == 0)
        {
            return $r['id'];
        }
        else
        {
            error_log("writes - " . $type . " - id");
            error_log("Error ". $this->db->errorno() . " : " . $this->db->error());
            die();
        }
    }

    public function get($data)
    {
        $id = $this->db->initKey($data['bin'], $data['table'], $data['key']);
        $status = $this->db->get($id, $record);

        if ($status == Aerospike::OK)
        {
            $record = $record['bins'];

            return $record;
        }
        else
        {
            // Log
            error_log($data['bin'] . " - " . $data['table'] . " - " . $data['key']);
            error_log("Error ". $this->db->errorno() . " : " . $this->db->error() . " : " . print_r ($id, true));
            return false;
        }
    }

    public function set($data, $record)
    {
        $id =  $this->db->initKey($data['bin'], $data['table'], $data['key']);
        $status = $this->db->put($id, $record);

        if ($status != Aerospike::OK)
        {
            // Log
            error_log($data['bin'] . " - " . $data['table'] . " - " . $data['key']);
            error_log("Error ". $this->db->errorno() . " : " . $this->db->error() . "\n");
        }
    }

    public function delete($data)
    {
        $id = $this->db->initKey($data['bin'], $data['table'], $data['key']);

        $this->db->remove($id);
    }
}

Here is my aerospike conf:

# Aerospike database configuration file.

service {
    user root
    group root
    paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
    pidfile /var/run/aerospike/asd.pid
    service-threads 4
    transaction-queues 4
    transaction-threads-per-queue 4
    proto-fd-max 15000
}

logging {
    # Log file must be an absolute path.
    file /var/log/aerospike/aerospike.log {
        context any info
    }
}

network {
    service {
        address any
        port 3000
    }

    heartbeat {
        mode multicast
        address 239.1.99.222
        port 9918
        interface-address 10.101.45.27
        interval 150
        timeout 10
    }

    fabric {
        port 3001
    }

    info {
        port 3003
    }
}

namespace cache {
    memory-size 1G
    replication-factor 2
    storage-engine memory
    default-ttl 0

    storage-engine device {
        file /opt/aerospike/data/cache.dat
        filesize 1G
        data-in-memory true
        write-block-size 128K
    }
}

namespace geoip {
    memory-size 4G
    replication-factor 2
    default-ttl 30

    storage-engine device {
        file /opt/aerospike/data/geoip.dat
        filesize 4G
        data-in-memory true
    }
}

namespace sessions {
    memory-size 1G
    replication-factor 2
    default-ttl 30

    storage-engine device {
        file /opt/aerospike/data/sessions.dat
        filesize 2G
        data-in-memory false
    }
}

namespace writes {
    memory-size 1G
    replication-factor 1
    default-ttl 7

    storage-engine device {
        file /opt/aerospike/data/writes.dat
        filesize 4G
        data-in-memory false
    }
}
@paulm17
Copy link
Author

paulm17 commented Aug 31, 2015

I've seen a few times now in the logs:

Aug 31 2015 18:00:06 GMT: WARNING (rw): (thr_rw.c::3233) unusual - setting generation 0<Digest>:0x4203052e5a17092669b030d2e7a43b2453fbf6eb

I presume when trying to write the session object?

@paulm17
Copy link
Author

paulm17 commented Aug 31, 2015

I also see this too:

After I have written data to aerospike:

Aug 31 2015 18:02:10 GMT: INFO (info): (thr_info.c::4885) namespace sessions: disk inuse: 1920 memory inuse: 64 (bytes) sindex memory inuse: 0 (bytes) avail pct 99 cache-read pct 100.00
Aug 31 2015 18:02:10 GMT: INFO (info): (thr_info.c::4885) namespace writes: disk inuse: 2304 memory inuse: 192 (bytes) sindex memory inuse: 0 (bytes) avail pct 99 cache-read pct 100.00

After just a few minutes:

Aug 31 2015 18:06:00 GMT: INFO (info): (thr_info.c::4885) namespace sessions: disk inuse: 0 memory inuse: 0 (bytes) sindex memory inuse: 0 (bytes) avail pct 99 cache-read pct 0.00
Aug 31 2015 18:06:00 GMT: INFO (info): (thr_info.c::4885) namespace writes: disk inuse: 0 memory inuse: 0 (bytes) sindex memory inuse: 0 (bytes) avail pct 99 cache-read pct 0.00

Now the file sizes are zero? Misconfiguration on aerospike configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant