MySQL crash after enormous row locks - mysql

I'm using MySQL 5.7.14 x64 on Windows Server 2008 R2
Sometimes (randomly times at day) mysql crashing with this stack trace
11:44:40 UTC - mysqld got exception 0x80000003 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.
key_buffer_size=8388608
read_buffer_size=65536
max_used_connections=369
max_threads=2800
thread_count=263
connection_count=263
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 3195125 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x2ee2b72b0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
13fe1bad2 mysqld.exe!my_sigabrt_handler()[my_thr_init.c:449]
1401c7979 mysqld.exe!raise()[winsig.c:587]
1401c6870 mysqld.exe!abort()[abort.c:82]
13ff1dd38 mysqld.exe!ut_dbg_assertion_failed()[ut0dbg.cc:67]
13ff1df51 mysqld.exe!ib::fatal::~fatal()[ut0ut.cc:916]
13ff0e008 mysqld.exe!buf_LRU_check_size_of_non_data_objects()[buf0lru.cc:1219]
13ff0f4ab mysqld.exe!buf_LRU_get_free_block()[buf0lru.cc:1303]
1400305cb mysqld.exe!buf_block_alloc()[buf0buf.cc:557]
13ff3767e mysqld.exe!mem_heap_create_block_func()[mem0mem.cc:319]
13ff37499 mysqld.exe!mem_heap_add_block()[mem0mem.cc:408]
13ffd87f4 mysqld.exe!RecLock::lock_alloc()[lock0lock.cc:1441]
13ffd795c mysqld.exe!RecLock::create()[lock0lock.cc:1534]
13ffd73a6 mysqld.exe!RecLock::add_to_waitq()[lock0lock.cc:1735]
13ffdcaaa mysqld.exe!lock_rec_lock_slow()[lock0lock.cc:2007]
13ffdc6ce mysqld.exe!lock_rec_lock()[lock0lock.cc:2081]
13ffd8cc7 mysqld.exe!lock_clust_rec_read_check_and_lock()[lock0lock.cc:6307]
140076fe3 mysqld.exe!row_ins_set_shared_rec_lock()[row0ins.cc:1502]
140072927 mysqld.exe!row_ins_check_foreign_constraint()[row0ins.cc:1739]
140072de8 mysqld.exe!row_ins_check_foreign_constraints()[row0ins.cc:1932]
140075d69 mysqld.exe!row_ins_sec_index_entry()[row0ins.cc:3356]
1400758a6 mysqld.exe!row_ins_index_entry_step()[row0ins.cc:3583]
140071b30 mysqld.exe!row_ins()[row0ins.cc:3721]
14007755a mysqld.exe!row_ins_step()[row0ins.cc:3907]
13ffaad50 mysqld.exe!row_insert_for_mysql_using_ins_graph()[row0mysql.cc:1735]
13fe7a7d3 mysqld.exe!ha_innobase::write_row()[ha_innodb.cc:7489]
13f6e5531 mysqld.exe!handler::ha_write_row()[handler.cc:7891]
13f8e54de mysqld.exe!write_record()[sql_insert.cc:1860]
13f8e916a mysqld.exe!read_sep_field()[sql_load.cc:1222]
13f8e7af4 mysqld.exe!mysql_load()[sql_load.cc:563]
13f716e86 mysqld.exe!mysql_execute_command()[sql_parse.cc:3649]
13f7194b3 mysqld.exe!mysql_parse()[sql_parse.cc:5565]
13f71267d mysqld.exe!dispatch_command()[sql_parse.cc:1430]
13f71368a mysqld.exe!do_command()[sql_parse.cc:997]
13f6d82bc mysqld.exe!handle_connection()[connection_handler_per_thread.cc:300]
140105122 mysqld.exe!pfs_spawn_thread()[pfs.cc:2191]
13fe1b93b mysqld.exe!win_thread_start()[my_thread.c:38]
1401c73ef mysqld.exe!_callthreadstartex()[threadex.c:376]
1401c763a mysqld.exe!_threadstartex()[threadex.c:354]
772859bd kernel32.dll!BaseThreadInitThunk()
773ba2e1 ntdll.dll!RtlUserThreadStart()
At this time active only 2 transactions
---TRANSACTION 1111758443, ACTIVE 565 sec
mysql tables in use 7, locked 7
7527 lock struct(s), heap size 876752, 721803 row lock(s), undo log entries 379321
MySQL thread id 166068, OS thread handle 1508, query id 112695582 localhost converter Waiting for table level lock
delete from pl
using
import_k2b_product_links ipl inner join k2b_products pSource on ipl.src_product = pSource.article and pSource.account_id = 22
inner join k2b_products pDest on ipl.dst_product = pDest.article and pDest.account_id = 22
inner join k2b_product_links pl on pl.src_product_id = pSource.id and pl.dst_product = pDest.id
where ipl.action = 1
---TRANSACTION 1111759716, ACTIVE 496 sec inserting, thread declared inside InnoDB 1
mysql tables in use 4, locked 4
7 lock struct(s), heap size 1304535248, 102060778 row lock(s), undo log entries 1
MySQL thread id 19436, OS thread handle 11664, query id 112301161 localhost exchange_central
LOAD DATA INFILE 'd:/kdm/temp/webCentral/ufrd1uwx.v2r'
INTO TABLE k2b_orders
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(id_status, dt, account_id, sms_sended, params, update_ts, exported, id_editor, dt_offset, device_id, gen, changer_device_id, total, creator_device_id, id, dt_server, device_category_id, original_params, order_num, sended, editor_comment, admin_comment)
I don't understand why transaction 1111758443 Waiting for table level lock?
And why transaction 1111759716 lock 102060778 rows while it load just only one from external file and it showed in undo log entries 1?
Which investigation I must done for known reason of this enormous locks and crash.
Thanks!

Two things make me think that the crash is not the 'real' problem.
Both queries in the log show 'huge' times, such as ACTIVE 565 sec.
And these are all quite large:
max_used_connections=369
max_threads=2800
thread_count=263
connection_count=263
When there are hundreds of threads simultaneously active, InnoDB stumbles over itself. Throughput stalls, and latency goes through the roof.
One cure is to avoid so many connections. This is sometimes best done at the client. What is the client? For example, Apache has MaxClients. A dozen Apaches, each with MaxClients = 50 would be trying to open 600 connections. Probably one Apache cannot effectively handle 50 threads at once. Lower that number.
Are there any VIEWs deceiving us?
Another thing to do is to pursue table level lock. Let's see SHOW CREATE TABLE for the tables involved. Check for appropriate indexes.
import_k2b_product_links: INDEX(action, ...)
k2b_products: INDEX(account_id, src_product) -- in either order
k2b_products: INDEX(account_id, dest_product) -- in either order
k2b_product_links: INDEX(src_product_id, dest_product_id) -- or PK, see below
Is k2b_product_links a many:many mapping table? If so, get rid of id auto_increment as discussed Here .
The index suggestions, if useful, could speed up the DELETE, thereby cutting down on possible contention.

Related

Does jOOQ use different connections to execute different queries?

I have a service which does some CRUD over a DB. Service uses jOOQ. This is what my transaction code looks like:
dslContext.transaction(conf -> {
// Query1
dslContext.update(Tables.TABLE1).set(Tables.TABLE1.COLUMN1, column1Value).where(Tables.TABLE1.COLUMN2.eq(column2Value)).execute();
// Query2
dslContext.insertInto(Tables.TABLE2).set(record1).execute();
});
Note that dslContext is global and we are using Apache DBCP2 BasicDataSource.
At high load, when the connection pool gets exhausted, all the threads gets stuck and leaves the DB in a state where only Query1 is executed.
Assuming that the connection pool size is N and is configured to wait indefinitely for a new thread, Hypothesis is that
At t=t0, N simultaneous threads try to execute Query1 in Connection1
At t=t1, these N threads move on to Query2 but doesn't get a connection from the pool and waits indefinitely.
Since threads are stuck, transaction didn't end and commit is not called, due to which N threads get stuck forever and never frees up. Rollback also doesn't happen because only way to bring back the system is to restart it. This leaves the DB in an inconsistent state.
Is my hypothesis correct ?
You're not using the transactional conf reference, you're using the outer dslContext, which isn't transactional - meaning each statement is run in its own transaction, just as if you weren't calling the transaction() method.
Do this instead:
dslContext.transaction(conf -> {
// Query1
conf.dsl().update(Tables.TABLE1)
.set(Tables.TABLE1.COLUMN1, column1Value)
.where(Tables.TABLE1.COLUMN2.eq(column2Value)).execute();
// Query2
conf.dsl().insertInto(Tables.TABLE2).set(record1).execute();
});

C3P0 Apparent Deadlock

My server used to see APPARENT DEADLOCK in the logs. I have several servers running behind a load balancer, and the interesting thing is I see the DEADLOCK occur on all servers at the same time (does anyone know why it affects all servers)?. During this time period, MySQL queries that normally take 200ms take >60 seconds. Here's what logs looked like then:
com.mchange.v2.async.ThreadPoolAsynchronousRunner: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector#58780f76
-- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#25ff87d4 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#10ccf7ef (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#3305ec37 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
Pending Tasks:
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#39cc9e5a
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#60d46f90
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#17509fea
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#b28bd63
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#56cbdc12
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#15a091b4
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#61ce325
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#48119520
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#4032fb7c
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#518eefff
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#30ea3b20
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#74960088
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#23a8fc7d
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#5ff0ee0
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#642d0644
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#207bc809
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#44d4936f
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#39a10d1b
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#3532334d
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#4bf79e62
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#2bd83398
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#1a202a2d
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#3eacda7f
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#495f5746
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#23f1f906
So I came to Stack Overflow and found this answer which suggested I set statementCacheNumDeferredCloseThreads to 1. I did this, and I see DEADLOCK less frequently and only on a few servers behind the load balancer instead of all.
The logs look a little different now, but during DEADLOCK period, queries still very long:
10 Oct 2018 06:33:32,037 [WARN] (Timer-0) com.mchange.v2.async.ThreadPoolAsynchronousRunner: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector#4f39ad63 -- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#34dee200 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#3727ee6b (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask#4afb8b9 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
Pending Tasks:
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#384a3b5b
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#7bc700b0
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#731bfd15
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#a88e9bf
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#63f18b56
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#20f0c518
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#caf7746
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#41a7a27d
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#2ee32a24
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#81df2e5
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#7f7fa1e7
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#337503f
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#34b2f877
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#53dfbede
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#512d5ddb
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#68a25969
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#4bf0754a
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#65770ba4
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#5e0f4154
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#249c22ed
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#6c8e5911
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#3179550f
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#15d8a795
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#50966489
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask#4ecee95b
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask#35640ca0
com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask#6550f196
com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask#6816399
com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask#3fbcd623
Pool thread stack traces:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]
com.mysql.jdbc.PreparedStatement.realClose(PreparedStatement.java:2765)
com.mysql.jdbc.StatementImpl.close(StatementImpl.java:541)
com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask.run(GooGooStatementCache.java:404)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]
com.mysql.jdbc.PreparedStatement.realClose(PreparedStatement.java:2765)
com.mysql.jdbc.StatementImpl.close(StatementImpl.java:541)
com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask.run(GooGooStatementCache.java:404)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]
com.mysql.jdbc.PreparedStatement.realClose(PreparedStatement.java:2765)
com.mysql.jdbc.StatementImpl.close(StatementImpl.java:541)
com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask.run(GooGooStatementCache.java:404)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Any idea how to fix this? I could try disable statement caching altogether but I'm concerned about the general performance hit. Some other relevant parameters:
minPoolSize = 30
maxPoolSize = 30
maxStatements = 100
unreturnedConnectionTimeout = 500
idleConnectionTestPeriod = 60
acquireIncrements = 3
C3p0 version = 0.9.1.2
Edit: I forgot to mention, during this improvement where I saw less deadlocks, I also increased maxStatements which could explain the improvement. However now I just see https://github.com/swaldman/c3p0/issues/53 which says version 0.9.2 introduces this new parameter statementCacheNumDeferredCloseThreads. My version is too old. I get no warnings/errors about this parameter not existing.
Maybe it's too late, but have you tried to increase the number of numHelperThreads?

Hive query does not begin MapReduce process after starting job and generating Tracking URL

I'm using Apache Hive.
I created a table in Hive (similar to external table) and loaded data into the same using the LOAD DATA LOCAL INPATH './Desktop/loc1/kv1.csv' OVERWRITE INTO TABLE adih; command.
While I am able to retrieve simple data from the hive table adih (e.g. select * from adih, select c_code from adih limit 1000, etc), Hive gives me errors when I ask for data involving slight computations (e.g. select count(*) from adih, select distinct(c_code) from adih).
The Hive cli output is as shown in the following link -
hive> select distinct add_user from adih;
Query ID = latize_20161031155801_8922630f-0455-426b-aa3a-6507aa0014c6
Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks not specified. Estimated from input data size: 1
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=
In order to set a constant number of reducers:
set mapreduce.job.reduces=
Starting Job = job_1477889812097_0006, Tracking URL = http://latize-data1:20005/proxy/application_1477889812097_0006/
Kill Command = /opt/hadoop-2.7.1/bin/hadoop job -kill job_1477889812097_0006
[6]+ Stopped $HIVE_HOME/bin/hive
Hive stops displaying any further logs / actions beyond the last line of "Kill Command"
Not sure where I have gone wrong (many answers on StackOverflow tend to point back to YARN configs (environment config detailed below).
I have the log as well but it contains more than 30000 characters (Stack Overflow limit)
My hadoop environment is configured as follows -
1 Name Node & 1 Data Node. Each has 20 GB of RAM with sufficient ROM. Have allocated 13 GB of RAM for the yarn.scheduler.maximum-allocation-mb and yarn.nodemanager.resource.memory-mb each with the mapreduce.map.memory.mb being set as 4 GB and the mapreduce.reduce.memory.mb being set as 12 GB. Number of reducers is currently set to default (-1). Also, Hive is configured to run with a MySQL DB (rather than Derby).
You should set the appropriate values to the properties show in your trace,
eg: Edit the properties in hive-site.xml
<property>
<name>hive.exec.reducers.bytes.per.reducer</name>
<value>67108864</value></property>
Looks like you have set mapred.reduce.tasks = -1, which makes Hive refer to its config to decide the number of reduce tasks.
You are getting an error as the number of reducers is missing in Hive config.
Try setting it using below command:
Hive> SET mapreduce.job.reduces=XX
As per official documentation: The right number of reduces seems to be 0.95 or 1.75 multiplied by (< no. of nodes > * < no. of maximum containers per node >).
I managed to get Hive and MR to work - increased the memory configurations for all the processes involved:
Increased the RAM allocated to YARN Scheduler and maximum RAM allocated to the YARN Nodemanager (in yarn-site.xml), alongside increasing the RAM allocated to the Mapper and Reducer (in mapred-site.xml).
Also incorporated parts of the answers by #Sathiyan S and #vmorusu - set the hive.exec.reducers.bytes.per.reducer property to 1 GB of data, which directly affects the number of reducers that Hive uses (through application of its heuristic techniques).

Only one node owns data in a Cassandra cluster

I am new to Cassandra and just run a cassandra cluster (version 1.2.8) with 5 nodes, and I have created several keyspaces and tables on there. However, I found all data are stored in one node (in the below output, I have replaced ip addresses by node numbers manually):
Datacenter: 105
==========
Address Rack Status State Load Owns Token
4
node-1 155 Up Normal 249.89 KB 100.00% 0
node-2 155 Up Normal 265.39 KB 0.00% 1
node-3 155 Up Normal 262.31 KB 0.00% 2
node-4 155 Up Normal 98.35 KB 0.00% 3
node-5 155 Up Normal 113.58 KB 0.00% 4
and in their cassandra.yaml files, I use all default settings except cluster_name, initial_token, endpoint_snitch, listen_address, rpc_address, seeds, and internode_compression. Below I list those non-ip address fields I modified:
endpoint_snitch: RackInferringSnitch
rpc_address: 0.0.0.0
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "node-1, node-2"
internode_compression: none
and all nodes using the same seeds.
Can I know where I might do wrong in the config? And please feel free to let me know if any additional information is needed to figure out the problem.
Thank you!
If you are starting with Cassandra 1.2.8 you should try using the vnodes feature. Instead of setting the initial_token, uncomment # num_tokens: 256 in the cassandra.yaml, and leave initial_token blank, or comment it out. Then you don't have to calculate token positions. Each node will randomly assign itself 256 tokens, and your cluster will be mostly balanced (within a few %). Using vnodes will also mean that you don't have to "rebalance" you cluster every time you add or remove nodes.
See this blog post for a full description of vnodes and how they work:
http://www.datastax.com/dev/blog/virtual-nodes-in-cassandra-1-2
Your token assignment is the problem here. An assigned token are used determines the node's position in the ring and the range of data it stores. When you generate tokens the aim is to use up the entire range from 0 to (2^127 - 1). Tokens aren't id's like with mysql cluster where you have to increment them sequentially.
There is a tool on git that can help you calculate the tokens based on the size of your cluster.
Read this article to gain a deeper understanding of the tokens. And if you want to understand the meaning of the numbers that are generated check this article out.
You should provide a replication_factor when creating a keyspace:
CREATE KEYSPACE demodb
WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor': 3};
If you use DESCRIBE KEYSPACE x in cqlsh you'll see what replication_factor is currently set for your keyspace (I assume the answer is 1).
More details here

Mysql InnoDB optimisation

I'm having some trouble understanding InnoDB usage - we have a drupal based DB (5:1 read:write) running on mysql (Server version: 5.1.41-3ubuntu12.10-log (Ubuntu)). Our current Innodb data/index sizing is:
Current InnoDB index space = 196 M
Current InnoDB data space = 475 M
Looking around on the web and reading books like 'High performance sql' suggest to have 10% increase on data size - i have set the buffer pool to be (data+index)+10% and noticed that the buffer pool was at 100%...even increasing about this to 896Mb still makes it 100% (even though the data + indexes are only ~671Mb?
I've attached the output of the innodb section of mysqlreport below. Pages free of 1 seems to be suggesting a major problem also as well. The innodb_flush_method is set at its default - I will investigate setting this to O_DIRECT but want to sort out this issue before.
__ InnoDB Buffer Pool __________________________________________________
Usage 895.98M of 896.00M %Used: 100.00
Read hit 100.00%
Pages
Free 1 %Total: 0.00
Data 55.96k 97.59 %Drty: 0.01
Misc 1383 2.41
Latched 0 0.00
Reads 405.96M 1.2k/s
From file 15.60k 0.0/s 0.00
Ahead Rnd 211 0.0/s
Ahead Sql 1028 0.0/s
Writes 29.10M 87.3/s
Flushes 597.58k 1.8/s
Wait Free 0 0/s
__ InnoDB Lock _________________________________________________________
Waits 66 0.0/s
Current 0
Time acquiring
Total 3890 ms
Average 58 ms
Max 3377 ms
__ InnoDB Data, Pages, Rows ____________________________________________
Data
Reads 21.51k 0.1/s
Writes 666.48k 2.0/s
fsync 324.11k 1.0/s
Pending
Reads 0
Writes 0
fsync 0
Pages
Created 84.16k 0.3/s
Read 59.35k 0.2/s
Written 597.58k 1.8/s
Rows
Deleted 19.13k 0.1/s
Inserted 6.13M 18.4/s
Read 196.84M 590.6/s
Updated 139.69k 0.4/s
Any help on this would be greatly apprectiated.
Thanks!