You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by joseph gao <ga...@gmail.com> on 2015/08/22 19:35:29 UTC

PrepareStatement BUG

I'm using cassandra 2.1.7 and datastax java drive 2.1.6
Here is the problem:

I use PrepareStatement for query like : SELECT * FROM somespace.sometable
where id = ?
And I Cached the PrepareStatement in my jvm;
When the table metadata has changed like a column was added;
And I use the cached PrepareStament , the data and the metadata(column
definations) don't match.
So I re-prepare the sql using session.prepare(sql) again, but i see the
code in the async-prepare callback part:

stmt = cluster.manager.addPrepare(stmt); in the SessionManager.java

this will return the previous PrepareStatement.
So it neither re-prepare automatically nor allow user to re-prepare!
Is this a bug or I use it like a fool?
-- 
------
Joseph Gao
PhoneNum:15210513582
QQ: 409343351

Re: PrepareStatement BUG

Posted by joseph gao <ga...@gmail.com>.
Yes, I discard using "SELECT *" statement and that fix the problem.

2015-10-02 1:50 GMT+08:00 Alexandre Dutra <al...@datastax.com>:

> Hello Joseph,
>
> CASSANDRA-7910 is fixed for Cassandra 2.1.3, but it still needs a fix
> driver-side: JAVA-420 <https://datastax-oss.atlassian.net/browse/JAVA-420>.
> Until this is not solved, the workaround (and the best practice) is to
> avoid using "SELECT *" statements and explicitly name the columns you need.
>
> Hope that helps,
>
> Alexandre
>
> On Fri, Aug 28, 2015 at 4:58 AM joseph gao <ga...@gmail.com> wrote:
>
>> if already fixed, my use case is wrong. But I think it's very normal case.
>>
>> 2015-08-28 10:57 GMT+08:00 joseph gao <ga...@gmail.com>:
>>
>>> I don't understand, does the issue mean 'don't use wildcard' or 'already
>>> fixed'?
>>>
>>> 2015-08-26 15:16 GMT+08:00 Peer, Oded <Od...@rsa.com>:
>>>
>>>> See https://issues.apache.org/jira/browse/CASSANDRA-7910
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *From:* joseph gao [mailto:gaojf.bokecc@gmail.com]
>>>> *Sent:* Wednesday, August 26, 2015 6:15 AM
>>>> *To:* user@cassandra.apache.org
>>>> *Subject:* Re: PrepareStatement BUG
>>>>
>>>>
>>>>
>>>> Hi, anybody knows how to resolve this problem?
>>>>
>>>>
>>>>
>>>> 2015-08-23 1:35 GMT+08:00 joseph gao <ga...@gmail.com>:
>>>>
>>>>
>>>> I'm using cassandra 2.1.7 and datastax java drive 2.1.6
>>>>
>>>> Here is the problem:
>>>>
>>>>
>>>>
>>>> I use PrepareStatement for query like : SELECT * FROM
>>>> somespace.sometable where id = ?
>>>>
>>>> And I Cached the PrepareStatement in my jvm;
>>>>
>>>> When the table metadata has changed like a column was added;
>>>>
>>>> And I use the cached PrepareStament , the data and the metadata(column
>>>> definations) don't match.
>>>>
>>>> So I re-prepare the sql using session.prepare(sql) again, but i see the
>>>> code in the async-prepare callback part:
>>>>
>>>>
>>>>
>>>> stmt = cluster.manager.addPrepare(stmt); in the SessionManager.java
>>>>
>>>>
>>>>
>>>> this will return the previous PrepareStatement.
>>>>
>>>> So it neither re-prepare automatically nor allow user to re-prepare!
>>>>
>>>> Is this a bug or I use it like a fool?
>>>>
>>>> --
>>>>
>>>> ------
>>>>
>>>> Joseph Gao
>>>>
>>>> PhoneNum:15210513582
>>>>
>>>> QQ: 409343351
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> ------
>>>>
>>>> Joseph Gao
>>>>
>>>> PhoneNum:15210513582
>>>>
>>>> QQ: 409343351
>>>>
>>>
>>>
>>>
>>> --
>>> ------
>>> Joseph Gao
>>> PhoneNum:15210513582
>>> QQ: 409343351
>>>
>>
>>
>>
>> --
>> ------
>> Joseph Gao
>> PhoneNum:15210513582
>> QQ: 409343351
>>
> --
> Alexandre Dutra
> Driver & Tools Engineer @ DataStax
>



-- 
------
Joseph Gao
PhoneNum:15210513582
QQ: 409343351

Re: PrepareStatement BUG

Posted by Alexandre Dutra <al...@datastax.com>.
Hello Joseph,

CASSANDRA-7910 is fixed for Cassandra 2.1.3, but it still needs a fix
driver-side: JAVA-420 <https://datastax-oss.atlassian.net/browse/JAVA-420>.
Until this is not solved, the workaround (and the best practice) is to
avoid using "SELECT *" statements and explicitly name the columns you need.

Hope that helps,

Alexandre

On Fri, Aug 28, 2015 at 4:58 AM joseph gao <ga...@gmail.com> wrote:

> if already fixed, my use case is wrong. But I think it's very normal case.
>
> 2015-08-28 10:57 GMT+08:00 joseph gao <ga...@gmail.com>:
>
>> I don't understand, does the issue mean 'don't use wildcard' or 'already
>> fixed'?
>>
>> 2015-08-26 15:16 GMT+08:00 Peer, Oded <Od...@rsa.com>:
>>
>>> See https://issues.apache.org/jira/browse/CASSANDRA-7910
>>>
>>>
>>>
>>>
>>>
>>> *From:* joseph gao [mailto:gaojf.bokecc@gmail.com]
>>> *Sent:* Wednesday, August 26, 2015 6:15 AM
>>> *To:* user@cassandra.apache.org
>>> *Subject:* Re: PrepareStatement BUG
>>>
>>>
>>>
>>> Hi, anybody knows how to resolve this problem?
>>>
>>>
>>>
>>> 2015-08-23 1:35 GMT+08:00 joseph gao <ga...@gmail.com>:
>>>
>>>
>>> I'm using cassandra 2.1.7 and datastax java drive 2.1.6
>>>
>>> Here is the problem:
>>>
>>>
>>>
>>> I use PrepareStatement for query like : SELECT * FROM
>>> somespace.sometable where id = ?
>>>
>>> And I Cached the PrepareStatement in my jvm;
>>>
>>> When the table metadata has changed like a column was added;
>>>
>>> And I use the cached PrepareStament , the data and the metadata(column
>>> definations) don't match.
>>>
>>> So I re-prepare the sql using session.prepare(sql) again, but i see the
>>> code in the async-prepare callback part:
>>>
>>>
>>>
>>> stmt = cluster.manager.addPrepare(stmt); in the SessionManager.java
>>>
>>>
>>>
>>> this will return the previous PrepareStatement.
>>>
>>> So it neither re-prepare automatically nor allow user to re-prepare!
>>>
>>> Is this a bug or I use it like a fool?
>>>
>>> --
>>>
>>> ------
>>>
>>> Joseph Gao
>>>
>>> PhoneNum:15210513582
>>>
>>> QQ: 409343351
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>> ------
>>>
>>> Joseph Gao
>>>
>>> PhoneNum:15210513582
>>>
>>> QQ: 409343351
>>>
>>
>>
>>
>> --
>> ------
>> Joseph Gao
>> PhoneNum:15210513582
>> QQ: 409343351
>>
>
>
>
> --
> ------
> Joseph Gao
> PhoneNum:15210513582
> QQ: 409343351
>
-- 
Alexandre Dutra
Driver & Tools Engineer @ DataStax

Re: PrepareStatement BUG

Posted by joseph gao <ga...@gmail.com>.
if already fixed, my use case is wrong. But I think it's very normal case.

2015-08-28 10:57 GMT+08:00 joseph gao <ga...@gmail.com>:

> I don't understand, does the issue mean 'don't use wildcard' or 'already
> fixed'?
>
> 2015-08-26 15:16 GMT+08:00 Peer, Oded <Od...@rsa.com>:
>
>> See https://issues.apache.org/jira/browse/CASSANDRA-7910
>>
>>
>>
>>
>>
>> *From:* joseph gao [mailto:gaojf.bokecc@gmail.com]
>> *Sent:* Wednesday, August 26, 2015 6:15 AM
>> *To:* user@cassandra.apache.org
>> *Subject:* Re: PrepareStatement BUG
>>
>>
>>
>> Hi, anybody knows how to resolve this problem?
>>
>>
>>
>> 2015-08-23 1:35 GMT+08:00 joseph gao <ga...@gmail.com>:
>>
>>
>> I'm using cassandra 2.1.7 and datastax java drive 2.1.6
>>
>> Here is the problem:
>>
>>
>>
>> I use PrepareStatement for query like : SELECT * FROM somespace.sometable
>> where id = ?
>>
>> And I Cached the PrepareStatement in my jvm;
>>
>> When the table metadata has changed like a column was added;
>>
>> And I use the cached PrepareStament , the data and the metadata(column
>> definations) don't match.
>>
>> So I re-prepare the sql using session.prepare(sql) again, but i see the
>> code in the async-prepare callback part:
>>
>>
>>
>> stmt = cluster.manager.addPrepare(stmt); in the SessionManager.java
>>
>>
>>
>> this will return the previous PrepareStatement.
>>
>> So it neither re-prepare automatically nor allow user to re-prepare!
>>
>> Is this a bug or I use it like a fool?
>>
>> --
>>
>> ------
>>
>> Joseph Gao
>>
>> PhoneNum:15210513582
>>
>> QQ: 409343351
>>
>>
>>
>>
>>
>> --
>>
>> ------
>>
>> Joseph Gao
>>
>> PhoneNum:15210513582
>>
>> QQ: 409343351
>>
>
>
>
> --
> ------
> Joseph Gao
> PhoneNum:15210513582
> QQ: 409343351
>



-- 
------
Joseph Gao
PhoneNum:15210513582
QQ: 409343351

Re: PrepareStatement BUG

Posted by joseph gao <ga...@gmail.com>.
I don't understand, does the issue mean 'don't use wildcard' or 'already
fixed'?

2015-08-26 15:16 GMT+08:00 Peer, Oded <Od...@rsa.com>:

> See https://issues.apache.org/jira/browse/CASSANDRA-7910
>
>
>
>
>
> *From:* joseph gao [mailto:gaojf.bokecc@gmail.com]
> *Sent:* Wednesday, August 26, 2015 6:15 AM
> *To:* user@cassandra.apache.org
> *Subject:* Re: PrepareStatement BUG
>
>
>
> Hi, anybody knows how to resolve this problem?
>
>
>
> 2015-08-23 1:35 GMT+08:00 joseph gao <ga...@gmail.com>:
>
>
> I'm using cassandra 2.1.7 and datastax java drive 2.1.6
>
> Here is the problem:
>
>
>
> I use PrepareStatement for query like : SELECT * FROM somespace.sometable
> where id = ?
>
> And I Cached the PrepareStatement in my jvm;
>
> When the table metadata has changed like a column was added;
>
> And I use the cached PrepareStament , the data and the metadata(column
> definations) don't match.
>
> So I re-prepare the sql using session.prepare(sql) again, but i see the
> code in the async-prepare callback part:
>
>
>
> stmt = cluster.manager.addPrepare(stmt); in the SessionManager.java
>
>
>
> this will return the previous PrepareStatement.
>
> So it neither re-prepare automatically nor allow user to re-prepare!
>
> Is this a bug or I use it like a fool?
>
> --
>
> ------
>
> Joseph Gao
>
> PhoneNum:15210513582
>
> QQ: 409343351
>
>
>
>
>
> --
>
> ------
>
> Joseph Gao
>
> PhoneNum:15210513582
>
> QQ: 409343351
>



-- 
------
Joseph Gao
PhoneNum:15210513582
QQ: 409343351

RE: PrepareStatement BUG

Posted by "Peer, Oded" <Od...@rsa.com>.
See https://issues.apache.org/jira/browse/CASSANDRA-7910


From: joseph gao [mailto:gaojf.bokecc@gmail.com]
Sent: Wednesday, August 26, 2015 6:15 AM
To: user@cassandra.apache.org
Subject: Re: PrepareStatement BUG

Hi, anybody knows how to resolve this problem?

2015-08-23 1:35 GMT+08:00 joseph gao <ga...@gmail.com>>:

I'm using cassandra 2.1.7 and datastax java drive 2.1.6
Here is the problem:

I use PrepareStatement for query like : SELECT * FROM somespace.sometable where id = ?
And I Cached the PrepareStatement in my jvm;
When the table metadata has changed like a column was added;
And I use the cached PrepareStament , the data and the metadata(column definations) don't match.
So I re-prepare the sql using session.prepare(sql) again, but i see the code in the async-prepare callback part:

stmt = cluster.manager.addPrepare(stmt); in the SessionManager.java

this will return the previous PrepareStatement.
So it neither re-prepare automatically nor allow user to re-prepare!
Is this a bug or I use it like a fool?
--
------
Joseph Gao
PhoneNum:15210513582
QQ: 409343351



--
------
Joseph Gao
PhoneNum:15210513582
QQ: 409343351

Re: PrepareStatement BUG

Posted by joseph gao <ga...@gmail.com>.
Hi, anybody knows how to resolve this problem?

2015-08-23 1:35 GMT+08:00 joseph gao <ga...@gmail.com>:

>
> I'm using cassandra 2.1.7 and datastax java drive 2.1.6
> Here is the problem:
>
> I use PrepareStatement for query like : SELECT * FROM somespace.sometable
> where id = ?
> And I Cached the PrepareStatement in my jvm;
> When the table metadata has changed like a column was added;
> And I use the cached PrepareStament , the data and the metadata(column
> definations) don't match.
> So I re-prepare the sql using session.prepare(sql) again, but i see the
> code in the async-prepare callback part:
>
> stmt = cluster.manager.addPrepare(stmt); in the SessionManager.java
>
> this will return the previous PrepareStatement.
> So it neither re-prepare automatically nor allow user to re-prepare!
> Is this a bug or I use it like a fool?
> --
> ------
> Joseph Gao
> PhoneNum:15210513582
> QQ: 409343351
>



-- 
------
Joseph Gao
PhoneNum:15210513582
QQ: 409343351