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

Batch with prepared queries #40

Open
sboo opened this issue Mar 24, 2015 · 12 comments
Open

Batch with prepared queries #40

sboo opened this issue Mar 24, 2015 · 12 comments

Comments

@sboo
Copy link

sboo commented Mar 24, 2015

Whenever I'm trying to use prepared queries in a batch, I get this error:

Exception in Error.php line 123:
Server error: java.lang.IndexOutOfBoundsException: index: 28, length: 749941 (expected: range(0, 137))

Here's what I'm executing:

$batchRequest = new Cassandra\Request\Batch(null, null, [
        'names_for_values' => true,
 ]);
$preparedData = $connection->prepare('INSERT INTO table (qid, rid, value, tsr, tsa)
VALUES (:qid,:rid,:value,:tsr,:tsa)');

$values = [
    'qid' => '1',
    'rid' => '1',
    'value' => '55',
    'tsr' => 1427225763000,
    'tsa' => 1427225763000,
];

$batchRequest->appendQueryId($preparedData['id'],
            Cassandra\Request\Request::strictTypeValues($values, $preparedData['metadata']['columns']));

$connection->syncRequest($batchRequest);

Am I missing something or is there an issue?

@shen2
Copy link
Member

shen2 commented Mar 25, 2015

Have you tried to use a general request?

@sboo
Copy link
Author

sboo commented Mar 25, 2015

Yeah, with normal queries it works as expected. I tried to debug the issue, but I don't quite understand the details yet of the protocol

@steambao
Copy link
Contributor

I tried this, and can confirm 'Server error: java.lang.IndexOutOfBoundsException' occurs when using "names_for_values = true" for batch requests. Using indexed array works fine.

@shen2
Copy link
Member

shen2 commented Mar 27, 2015

@steambao The code is strictly obey the protocol. It seems like a bug of Cassandra.
Can you have a try to find a way to avoid this problem?

@steambao
Copy link
Contributor

steambao commented Apr 1, 2015

Had a look today. Besides turning off names for values, not sure how or why the error. Looks according to spec as far as I can tell.

I wonder if its possible to compare the generated frame in this driver against a generated batch frame from an official driver like https://github.com/datastax/csharp-driver using same cql and bind variables...

@markharding
Copy link

This used to work in v0.5.2 (https://packagist.org/packages/duoshuo/php-cassandra)... and if i revert back to this version the request works fine. Any ideas of what changed since then to cause the bug?

@markharding
Copy link

This became broken in commit 79a046d. It works in 8268f9a

@firnas
Copy link

firnas commented Apr 30, 2015

Line Request:122 causes the exception, (tested in cassandra enviroments 2.1.2 and 2.1.4). It makes no sense because the code looks correct according to specification.

@markharding
Copy link

I wonder if binary value could be affected by string case (ie. upper or lower)?

@withings-sas
Copy link

Hi, we have the same issue, but it does not work in v0.5.2 too: it looks like it works but in fact "names_for_values" is ignore in v0.5.2 so if you give the args in the good orders, it works.. But if you force names_for_values the same error occurs:

Caught exception: Server error: java.lang.IndexOutOfBoundsException: index: 241, length: 681061 (expected: range(0, 409))

@withings-sas
Copy link

In fact names_for_values never worked for batch queries, I tested several version and all returns the same error

@shen2
Copy link
Member

shen2 commented Jul 11, 2015

Hi, all.
It seems to be a bug of Cassandra.
So, the best solution is to throw exception when use NAMES_FOR_VALUES flag in batch request.
see e8f94d2

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

6 participants