Skip to content

Error when the difference between test_by_score and tests rows is > 0 and you try to run node server #32

@brando90

Description

@brando90

Currently I was trying to run node server and the following error comes up:

events.js:72
        throw er; // Unhandled 'error' event
              ^
TypeError: Cannot read property 'hash' of undefined
    at CassandraBackend.initTestPQ (/home/brandomiranda/Documents/6.S194/testreduce/CassandraBackend.js:154:44)
    at CassandraBackend.queryCB (/home/brandomiranda/Documents/6.S194/testreduce/CassandraBackend.js:135:17)
    at Object.callback (/home/brandomiranda/Documents/6.S194/testreduce/node_modules/node-cassandra-cql/index.js:248:16)
    at Connection.handleFrame (/home/brandomiranda/Documents/6.S194/testreduce/node_modules/node-cassandra-cql/lib/connection.js:244:15)
    at FrameParser.<anonymous> (/home/brandomiranda/Documents/6.S194/testreduce/node_modules/node-cassandra-cql/lib/connection.js:45:12)
    at FrameParser.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at FrameParser.Readable.push (_stream_readable.js:127:10)

To summarize what that error means is that its trying to get the attribute .hash from an undefined object:

var lastCommit = this.commits[commitIndex].hash;

It happens on on the following line for me:
https://github.com/gwicke/testreduce/blob/master/CassandraBackend.js#L136

I am 99% certain that the error is triggered because the following line of code executes:

https://github.com/gwicke/testreduce/blob/master/CassandraBackend.js#L129

Which makes initTestPQ to be called again which makes indexing something out of range which returns a undefined that does not have a .hash attribute.

Line 129 is called when the difference in lines between tests and test_by_score is >0. In my case I called the usual importCassandra.js to start the database.keyspace:

https://github.com/gwicke/testreduce/blob/master/articles/importCassandra.js

and then manually inserted one commit to the database with the following command:

"INSERT INTO commits (hash, tid, keyframe) VALUES ('0b5db8b91bfdeb0a304b372dd8dda123b3fd1ab6', now(), true)"

[NOTE: I inserted the ' next to the hash because otherwise, github tries to link it to some actual commit. When writing it to cqlsh, make sure to remove the ' because it should not be there as a cql command]

When I ran importCassandra, I ran it with some languages, I don't remember exactly which ones I ran but the state of my database is the following (I probably ran it with en, ar and sv languages, since those are the only abbreviations I really know):

tests table has 18592 rows and the test_by_score table has 18591.

Their difference is > 0 and that is why the code I pointed out is even running and crashing (the reason is crashing is because commitIndex = 1, and there isn't a second commit, so indexing the array returns undefined and accessing the .hash property of undefined of course fails).

On line 129 of CassandraBackend.js the difference between numTestsLeft - results.rows.length > 0, which is why the redo initTestPQ function runs.

Not sure why the difference is positive or why it would matter. My guesses are that for each commit we want their corresponding test score, so thats why they have to have the same number of rows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions