Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

berkeley db-bulk load example

User_2ZA3ODec 25 2020

Hi,
I am trying to bulk load and read from BDB-Btree with "unsigned long int" keys.
When I make some minor modifications in the Bulkexample code, the tree is not being generated correctly.
What I have done: I changed the key type as u_int32_t and changed the variables type in compare_int function as well.
It seemed to me the problem is about alignment.
Then, I put my key data in byte array and used marshalling/unmarshalling techniques, still I cannot read data sorted by key :(
The code has something like the below
u_int32_t keyvalue=rnd->nextUniformUnsignedLong(); // rnd is my random generator
uint32_t sizeOfKey = sizeof(u_int32_t);
uint8_t *bufkey = new uint8_t[sizeOfKey]; // allocate a buffer area.
uint8_t *it = bufkey; // pointer variable to iterate over the buffer.
memcpy(it, &keyvalue, sizeOfKey);

uint8_t *bufdata = new uint8_t[DATALEN]; // allocate a buffer area.
it = bufdata; // pointer variable to iterate over the buffer.
memcpy(it, &(data_val->id), sizeof(int));
it += sizeof(int);
memcpy(it, data_val->str, STRLEN);
...
if (ptrkd->append(bufkey, sizeOfKey,
bufdata, DATALEN) == false)
throwException(dbenv,
txnp, EXIT_FAILURE,...)

In the compare function:
uint32_t sizeOfKey = sizeof(u_int32_t); //uint_fast32_t
uint8_t *it = (uint8_t *)a->get_data(); // allocate a total buffer area. Write explicit size for the array, do not use sizeof()
memcpy(&ai, it, sizeOfKey);
it=nullptr;
it = (uint8_t*) b->get_data(); // allocate a total buffer area. Write explicit size for the array, do not use sizeof()
memcpy(&bi, it, sizeOfKey);

// memcpy(&ai, a->get_data(), sizeof(int));
// memcpy(&bi, b->get_data(), sizeof(int));
return (ai - bi);
Similiar problems occur when I try to load b-tree with double keys..It does not sort correctly.
Thanks for the help. Good holidays..

Comments

Answer

You want to use MySQL Router as the load balancer for the cluster.  If you are running a load balancer to get to the application that is fine but bot for InnoDb Cluster traffic.

Marked as Answer by user619241 · Sep 27 2020
lefred-MySQL-Oracle

Hello,

Putting MySQL Router on a dedicated server (or more) is OK, but I really don't understand the benetifs to put it on cluster nodes !

Maybe your loadbalancer doesn't close connections ? Like that it's difficult to answer. Check the connectio status and variables in MySQL and check the connections in the router.

Regards,

Place Router on the application nodes not on the InnoDB cluster nodes.  See https://dev.mysql.com/doc/mysql-router/8.0/en/

user619241

Hello,

I agree with all the answers. I still don't understand this statement:

"You want to use MySQL Router as the load balancer for the cluster."

Is MySQL Router a load balancer by itself? Then does the Router itself have HA capability?

Thanks,

- Xinhuan

MySQL Router will load balance the queries to innoDB Cluster or ReplciaSet.

user619241

In my test environment, I installed multiple mysqlrouter and start them. I'm testing if one of mysqlrouter process stop, can client connection be failed over to another mysqlrouter instance automatically. I tested with Keepalived. So far it wasn't successful. It looks like mysqlrouter is Single-Point-of-Failure.

- Xinhuan

1 - 6

Post Details

Added on Dec 25 2020
2 comments
123 views