February 6, 2018


When using Cassandra you quickly learn that preparing queries is the way to go. It makes them about a billion times faster. But sometimes you need to do fancy things to your queries like set up a specific retry policy or set up a specific consistency policy that is active for just that query. I found few examples of how to do this in the documentation or on the internet. So, in Python, here's how to do both.

__queries = {
    "select": None,  # store the prepared select query
}

def select_data(foo):
    if (__queries["select"] is None):
        __queries["select"] = session.prepare("""
            SELECT col1, col2
            FROM mykeyspace.mytable
            WHERE col3 = :foo
        """)
        __queries["select"].retry_policy = cassandra.policies.DowngradingConsistencyRetryPolicy()
    query = __queries["select"]

    bound = query.bind({"foo": foo})
    bound.consistency_level = cassandra.ConsistencyLevel.QUORUM

    rows = session.execute(bound)
    for row in rows:
        pass

Tada.

January 7, 2018


Rather than fill up an entire 6TB HDD with Time Machine backups I learned that you have two options to keep that in check. First you can limit the size of your backups by running this command where the number is megabytes: sudo defaults write /Library/Preferences/com.apple.TimeMachine MaxSize -integer XX. Second, you can always go back and delete old backups by using tmutil delete followed by hdiutil compact.

December 2, 2017


Amazon AWS's EC2 started supporting IPv6 earlier this year. When I spun up my new Debian 9 Stretch instance a few months ago it came with IPv6 support. It started out working just fine. However, after one week, consistently, my instance would always lose its IPv6 route. The host would keep its IP address but any attempt to use ping6 or a traceroute6 would return "network unreachable" and ip -6 route would show no gateway. (I even set accept_ra 1 in the network interfaces configuration, among other things that I tried.) Lots of changes to my configuration yielded no results. Since I can't get a console using EC2 the only way to test would be to make a configuration change, reboot, and then wait a week to see if IPv6 still works. So today I finally just removed my AAAA records.

October 26, 2017


So, when postgrey starts it puts a pid file in the directory /var/run/postgrey. On Debian 9 /var/run is on a temporary file system and is erased on reboot. The default init script for postgrey on does NOT create the directory for its pid file. So then you reboot the host and postgrey doesn't start and postfix returns errors about the mail server not being configured correctly and your mail all bounces for several days. What the hell, Debian.

October 2, 2017


My biggest complaints about Cassandra are that it doesn't support ad hoc queries and that it doesn't support referential integrity. It's too easy to lose track of bad data or data that should have been deleted.

September 27, 2017


I wonder if I really need seventeen years of emails in my inbox.

September 17, 2017



About

Location Seattle, WA
First post September 6, 2004
Total posts 5,961

Tags

  1. 1,799
  2. 695
  3. 633
  4. 585
  5. 554
  6. 497
  7. 268
  8. 193
  9. 193
  10. 139
  11. 131
  12. 106
  13. 104
  14. 86
  15. 78
  16. 70
  17. 58
  18. 57
  19. 41
  20. 26
  21. 1
Load the RSS feed for entries or for comments.