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

Support for org.apache.cassandra.db.marshal-namespaced custom types (See #151) #154

Merged
merged 3 commits into from
May 1, 2014

Conversation

nemosupremo
Copy link
Contributor

I was unable to get a word from the cassandra developer mailing list (http://www.mail-archive.com/dev@cassandra.apache.org/msg07178.html) so I can't say I am bringing any sort of official functionality. As stated in my issue (#151) instead of seeing the native type over the wire for timestamps, I was seeing this custom type. Seeing how we were unable to continue without a fix in the Go driver I have simply opted to develop this fix.

The issue didn't occur in the official Python driver, so I have opted to duplicate the functionality there (Can be seen @ https://github.com/datastax/python-driver/blob/master/cassandra/cqltypes.py and https://github.com/datastax/python-driver/blob/master/tests/unit/test_types.py).

The first commit fixes what appears to be a type in the String function of TypeInfo. The next two are the relevant implementations and tests.

@0x6e6562
Copy link
Contributor

On a first pass, this looks OK to me, but it would be good to know what version of Cassandra that you tested this against. Also, what was the CQL schema definition that prompts the relevant server side behavior?

@nemosupremo
Copy link
Contributor Author

This was tested against Cassandra 2.0.6.

Schema in question:

CREATE TABLE video_daily (
  videoTag text,
  ts timestamp,
  stats blob,
  delta blob,
  PRIMARY KEY (videoTag, ts)
) WITH CLUSTERING ORDER BY (ts DESC);

This same schema however on my most recent tests returns the native type timestamp.

@0x6e6562
Copy link
Contributor

I assume you meant to post

WITH CLUSTERING ORDER BY (ts DESC);

?

@nemosupremo
Copy link
Contributor Author

Yes, its ts DESC. Was sloppy typing it out.

@0x6e6562
Copy link
Contributor

What is bugging me is that there is a virtually equivalent schema definition in the cqlc test suite, which I have been running regularly against 2.0.6. The relevant test case for this is here. So I'm a bit baffled as to what the actual difference is here (I'm not discounting what you're actually seeing in practice, it's just a curious one but it seems hard to reproduce).

@0x6e6562
Copy link
Contributor

BTW, I may have said this before, but I get the impression that posting to the Cassandra dev list is like writing to /dev/null, but I'm not sure because I don't subscribe to it. There is, however, more visible life on the regular Cassandra user list.

@0x6e6562
Copy link
Contributor

Is there any movement on this?

@nemosupremo
Copy link
Contributor Author

Still no feedback from Cassandra proper. On another note for 2.1, custom types will be handled through this mechanism, so you think this shouldn't be included in the driver, there should be some way to expose the custom type from the driver rather than just "Failed to unmarshal custom"

@0x6e6562
Copy link
Contributor

0x6e6562 commented May 1, 2014

That's an interesting point about 2.1. Currently we don't have any explicit support for 2.1 other than try it and see, but we are trying to put through a patch to regression test the driver against multiple versions of Cassandra (see #159). This could serve as basis to test out any handling of 2.1 specific stuff - if you can get a test case to fail against 2.1, that this patch would resolve, then that would definitely be a strong reason to merge this.

@0x6e6562
Copy link
Contributor

0x6e6562 commented May 1, 2014

BTW, we're not stalling on this patch, but I was wondering how your example schema differs from the test suite that I referenced last week?

@nemosupremo
Copy link
Contributor Author

The schema doesn't differ. After an upgrade from 1.2 to 2.0, a column family of mine that had been defined timestamp, had become custom<org.apache.cassandra.db.marshal.datetype> for reasons unclear to me - which had caused gocql to reject my queries, but the Java and Python java seemed to handle it fine.

I'll try again in finding more information about the issue through JIRA or emailing a committer.

@nemosupremo
Copy link
Contributor Author

Finally got some info on the error I was seeing on the IRC channel, its related to this JIRA issue - https://issues.apache.org/jira/browse/CASSANDRA-5723.

Basically from 1.2 to 2.0, they changed the cassandra time type from org.apache.cassandra.db.marshal.datetype to org.apache.cassandra.db.marshal.datetimetype` and the bug I'm experiencing actually seems to be a problem with cassandra.

@nemosupremo
Copy link
Contributor Author

So here is a response I got over IRC from a datastax dev:

[08:02:43]  <pcmanus>    You have 2 choices: You can update your tables 
(with cqlsh, do a ALTER .. ALTER TYPE x timestamp, to switch to the new TimestampType). 
This is fine if you know you never inserted pre-epoch timestamp. 
Or you can ask the go driver authors to special case for it (which is what the python and java driver do).
[08:02:51]  <pcmanus>    Or both really.

So again this behavior was caused by a change in the way Cassandra handles timestamps, so a test against cassandra isn't really possible. A fix for me seems to be just doing ALTER TYPE against all my tables. So finally the only reason to really continue with this merge is if you want to match the behavior of the Java/Python drivers in regards to handling this case.

@0x6e6562
Copy link
Contributor

0x6e6562 commented May 1, 2014

OK, on that basis, I'm down with this change - if @phillipCouto, @tux21b or @Zariel agrees, then we should get on and merge it.

@Zariel
Copy link
Contributor

Zariel commented May 1, 2014

LGTM, thanks very much!

Zariel added a commit that referenced this pull request May 1, 2014
Support for org.apache.cassandra.db.marshal-namespaced custom types (See #151)
@Zariel Zariel merged commit 4256984 into apache:master May 1, 2014
@0x6e6562
Copy link
Contributor

So it turns out that somebody has gone to the effort of identifying the root cause of this behavior, so we might not need this workaround going forwards: https://issues.apache.org/jira/browse/CASSANDRA-7576

dkropachev pushed a commit to go-auxiliaries/gocql that referenced this pull request May 31, 2024
The java driver has the feature to automatically avoid slow replicas
by doing simple heuristics. This is one of the key feature to have a
stable latency.

This commit adds additional field in tokenAwareHostPolicy to control
if the feature is enabled and what is the maximum in flight threshold.

If feature is enabled driver sorts the replicas to first try those
with less than specified maximum in flight connections.

Fixes: apache#154
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

Successfully merging this pull request may close these issues.

3 participants