Thanks for the experiment.  It's always better to try things than to
theorize...

There is no such thing as a perfect monitoring test...  But the general
idea is to test as much as you can -- as cheaply as you can - so you can
afford to run it frequently.

One interesting thing about the OCF resource agent API - the invoker can
specify how expensive a test they want to execute.  The monitoring code
doesn't have to implement more than one kind of test - but it can
implement as many as it wants.  If the requested level of test isn't
implemented, it defaults to the next lower level of test.

But it means at least as far as the monitoring API is concerned, you can
run a simple test every 10 seconds, a moderate test every 5 minutes and
a somewhat more expensive test once an hour (for example).

In general, you want the monitoring agent's default monitoring queries
to work in every database.

>From my experience in other areas, once you start doing disk-touching
experiments, everything that might touch the disk starts failing pretty
soon...  I/O queues fill up, threads block, caches get locked, weird
stuff starts happening...

Monitoring operations are timed.  So, if it hangs, it will be declared a
failure pretty soon...

In our implementation (and also in Pacemaker), operations are started in
process groups.  If the operation times out, the entire process group is
killed - with signal escalation to -9 if they don't terminate soon enough...


On 12/18/2013 12:10 PM, Wes Freeman wrote:
> I tried it with a USB key... just to see. Started neo4j server, made a
> few queries, and unplugged the drive unsafely.
>
> If you have RETURN 1; cached in the query cache it seems to continue
> to work after unplugging the drive (doesn't work if not cached), in
> addition "RETURN X" where X is any number continues to work. If you
> change the type of X, it will fail. All other node-hitting queries
> failed, even if cached.
>
> Interesting experiment.
>
> Wes
>
> On Wed, Dec 18, 2013 at 1:47 PM, Wes Freeman <[email protected]
> <mailto:[email protected]>> wrote:
>
>     True, but it's possible for other queries to not touch the
>     datastore as well. Would be interesting to try to break it and see
>     what happens. 
>     Unplug a disk to see if neo still responds to read queries that
>     are still in the cache. :)
>
>     And yeah you're right, ::1 doesn't work in the config file (which
>     is odd), but if you bind to :: you can connect to ::1. Just tested
>     with my go driver using the following connection string:
>        db, err := sql.Open("neo4j-cypher", "http://[::1]:7474/";)
>
>     Wes
>
>     On Wed, Dec 18, 2013 at 1:22 PM, Alan Robertson <[email protected]
>     <mailto:[email protected]>> wrote:
>
>         I meant to say "::1".  Right now, it won't hear local only
>         ipv6 connections...
>
>         But your suggested query doesn't have to touch the data store
>         at all.  Right?
>
>         I would assume that either of the others I gave would touch
>         the data store, and would typically fail of the data store was
>         hung or broken...
>
>         I would assume your suggested query would not touch the data
>         store.
>
>         Is that a correct understanding?
>
>
>
>
>         On 12/18/2013 11:13 AM, Wes Freeman wrote:
>>         You can make it listen on :: if you set it in
>>         neo4j-server.properties:
>>         # Let the webserver only listen on the specified IP. Default
>>         is localhost (only
>>         # accept local connections). Uncomment to allow any
>>         connection. Please see the
>>         # security section in the neo4j manual before modifying this.
>>         org.neo4j.server.webserver.address=::
>>
>>         My favorite ultra-simple 2.0 query is "RETURN 1;"--which
>>         works even if db is totally empty.
>>
>>         Wes
>>
>>         On Wed, Dec 18, 2013 at 10:56 AM, Alan Robertson
>>         <[email protected] <mailto:[email protected]>> wrote:
>>
>>             Thanks for the explanation.  I have always (mistakenly)
>>             thought of the type of the relationship as a sort of
>>             property.
>>
>>             In any case, the script seems to work quite nicely, and
>>             is easy to autogenerate the parameters for from
>>             Assimilation discovery information.
>>
>>             I discovered something surprising (a bug?) about curl --
>>             unless I give it the -g flag (don't expand globs), then
>>             it doesn't like ipv6 IP/port combinations - like
>>             [::ffff:127.0.0.1]:7474.  IMHO, it shouldn't be trying to
>>             glob IP addresses...
>>
>>             I noticed that neo4j doesn't appear to be ipv6 compliant
>>             (i.e., it doesn't listen on '::').  Is that intentional?
>>
>>             In any case, the script seems to give neo4j some trivial,
>>             but meaningful exercise.  You have to parse the query,
>>             optimize it, create a query plan, execute it, walk
>>             through the results, convert them to JSON and send them
>>             back out the REST interface.  Quite a few things have to
>>             be working for it to succeed.
>>
>>             Do you have a favorite trivial query that will succeed in
>>             any non-empty neo4j database?
>>
>>             Do you have a better grep pattern for matching correct
>>             output?
>>
>>
>>
>>             On 12/17/2013 11:18 PM, Michael Hunger wrote:
>>>             return type(r)
>>>
>>>             Empty curly braces mean no props
>>>
>>>             Sent from mobile device
>>>
>>>             Am 18.12.2013 um 06:41 schrieb Alan Robertson <[email protected]> 
>>> <mailto:[email protected]>:
>>>
>>>>             The query in the script below produces the following output:
>>>>             
>>>> {"results":[{"columns":["one","rel","two"],"data":[{"row":[{"domain":"metadata","nodetype":"CMAclass","name":"HbRing"},{},{"domain":"metadata","nodetype":"CMAclass","name":"CMAclass"}]}]}],"errors":[]}
>>>>
>>>>             What I noticed is that the relationship shows up as {}.  Do I 
>>>> need to
>>>>             change the query to get the relationship type?  [See the 
>>>> script below
>>>>             for the query]
>>>>
>>>>             In any case, below is a script which does a passable job of 
>>>> seeing if
>>>>             Neo4j is operational (and not dead, comatose, or laying on the 
>>>> ground
>>>>             twitching)...  I'm going to write an OCF resource agent using 
>>>> it - so I
>>>>             can monitor neo4j "properly".  And I could also make it 
>>>> highly-available
>>>>             using Pacemaker...
>>>>
>>>>             It can use either wget or curl to talk to Neo4j.
>>>>
>>>>             #
>>>>             #    Simple script to monitor Neo4j for basic operation
>>>>             #
>>>>             #    Potential inputs to this script are:
>>>>             #    ipport:    IP-port combination of the neo4j REST server
>>>>             #    cypher:    Cypher query string
>>>>             #    regex:     Regular expression to match server output 
>>>> against
>>>>             #    grepflags: flags to give grep
>>>>             ipport='127.0.0.1:7474 <http://127.0.0.1:7474>'
>>>>             ipport='[::ffff:127.0.0.1]:7474'
>>>>             cypher="START one=node(*) RETURN one LIMIT 1"
>>>>             #    Need at least one node and one relationship for this one 
>>>> to succeed...
>>>>             cypher="START one=node(*) MATCH one-[rel]->two RETURN one, 
>>>> rel, two LIMIT 1"
>>>>             regex='^{ *"results" *: *\[.*\] *, *"errors" *: *\[ *\] *}$'
>>>>             grepflags=""
>>>>             #
>>>>             #    Other variables in the script
>>>>             #    queryjson:    JSON-encapsulated version of cypher query
>>>>             #    committrans:  url suffix for committing transactions in 
>>>> one go
>>>>             #    URL:          URL to give to Neo4j REST service
>>>>             #    header:       Extra header information to give REST 
>>>> service (i.e.,
>>>>             Content-type)
>>>>             queryjson="{\"statements\" : [ { \"statement\" : \"$cypher\" } 
>>>> ] }"
>>>>             committrans='db/data/transaction/commit'
>>>>             URL=http://${ipport}/${committrans}
>>>>             header='Content-type: application/json'
>>>>             use_wget=1
>>>>
>>>>             runquery() {
>>>>                if
>>>>                  [ "$use_wget" -eq 1 ]
>>>>                then
>>>>                  wget -q    --header="${header}" --post-data="$queryjson" 
>>>>             --output-document=- $URL
>>>>                else
>>>>                  curl -s -g --header "${header}" --data      "$queryjson"  
>>>> --output
>>>>             -          $URL
>>>>                fi
>>>>             }
>>>>             monitor() {
>>>>                runquery | grep ${grepflags} "${regex}" >/dev/null
>>>>             }
>>>>             runquery
>>>>             monitor
>>>>             rc=$?
>>>>             echo $rc
>>>>             exit $rc
>>>>
>>>>
>>>>
>>>>             -- 
>>>>                Alan Robertson <[email protected]> <mailto:[email protected]> - 
>>>> @OSSAlanR
>>>>
>>>>             "Openness is the foundation and preservative of friendship...  
>>>> Let me claim from you at all times your undisguised opinions." - William 
>>>> Wilberforce
>>>>
>>>>             -- 
>>>>             You received this message because you are subscribed to the 
>>>> Google Groups "Neo4j" group.
>>>>             To unsubscribe from this group and stop receiving emails from 
>>>> it, send an email to [email protected] 
>>>> <mailto:[email protected]>.
>>>>             For more options, visit 
>>>> https://groups.google.com/groups/opt_out.
>>
>>
>>             -- 
>>                 Alan Robertson <[email protected]> <mailto:[email protected]> - 
>> @OSSAlanR
>>
>>             "Openness is the foundation and preservative of friendship...  
>> Let me claim from you at all times your undisguised opinions." - William 
>> Wilberforce
>>
>>
>
>
>         -- 
>             Alan Robertson <[email protected]> <mailto:[email protected]> - @OSSAlanR
>
>         "Openness is the foundation and preservative of friendship...  Let me 
> claim from you at all times your undisguised opinions." - William Wilberforce
>
>
>


-- 
    Alan Robertson <[email protected]> - @OSSAlanR

"Openness is the foundation and preservative of friendship...  Let me claim 
from you at all times your undisguised opinions." - William Wilberforce

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to