Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
VAL="8dbf075d5e3d34aa45a74e5d5d4dab71"
NAME=eth
BITSIZE=$((4*${#VAL}))
K1=$(python2 -c "print '0'*($BITSIZE/4)")
echo -e "$K1\n\n$VAL\n\n" | ctkmu c -tgs -n $NAME -aX -s0 -k2 -z$BITSIZE
VAL="effc87acb52ccdfd9aef0e1bd3e04c4b"
NAME=bch
BITSIZE=$((4*${#VAL}))
K1=$(python2 -c "print '0'*($BITSIZE/4)")

We want to use CockroachDB instead of Postgres as database for Keycloak. CockroachDB is a distributed and lockless database.

Thus there is conceptually some differences with Postgres.

In case of concurrent transaction, it may happens that one of the transaction is aborted, the application is in charge of retry the transaction. The way to do it with cockroach is described in https://www.cockroachlabs.com/docs/stable/transactions.html#client-side-transaction-retries.

In summary, we have to create a SAVEPOINT just after the BEGIN transaction. Once all the statements are executed, release the SAVEPOINT.If the is a transaction fails due to concurrent Tx, we rollback to the savepoint and reexecute the statements.

This is the standard behavior of Cockroach, so we need to implement this mechanism for each DB calls.

#Fedora devel-env setup

From nothing to up and running dev environment [With Fedora]

  • Currently working on Fedora 23
  • Some of the dependencies are discovred by try and try and try again and fail fail fail then it's work...

Welcome in MS (AkA I don't care about RFC world)

package main
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/vulcand/oxy/forward"
"github.com/vulcand/oxy/testutils"
"strconv"
)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2013:
# Sébastien Pasche, braoru@gmail.com
#
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
# Copyright (C) 2015-:
# Pasche Sebastien, sebastien.pasche@leshop.ch
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@braoru
braoru / error
Created October 14, 2016 09:36
E1014 11:31:45.018967144 10074 ev_epoll_linux.c:1178] pollset_kick: {"created":"@1476437505.018940010","description":"Kick Failure","file":"src/core/lib/iomgr/ev_epoll_linux.c","file_line":258,"referenced_errors":[{"created":"@1476437505.018938087","description":"OS Error","errno":3,"file":"src/core/lib/iomgr/ev_epoll_linux.c","file_line":1091,"os_error":"No such process","syscall":"pthread_kill"}]}
E1014 11:31:45.018992716 10074 completion_queue.c:295] Kick failed: {"created":"@1476437505.018940010","description":"Kick Failure","file":"src/core/lib/iomgr/ev_epoll_linux.c","file_line":258,"referenced_errors":[{"created":"@1476437505.018938087","description":"OS Error","errno":3,"file":"src/core/lib/iomgr/ev_epoll_linux.c","file_line":1091,"os_error":"No such process","syscall":"pthread_kill"}]}
E1014 11:31:45.019075543 9789 tcp_server_posix.c:393] Failed accept4: Invalid argument
#!/usr/bin/python -i
from concurrent import futures
import logging
import time
import signal
import datetime
import pykka
@braoru
braoru / test.py
Last active October 7, 2016 07:07
#!/usr/bin/python -i
from concurrent import futures
import logging
import time
from os import getpid
import datetime
from circuits import Component, Event, Debugger, handler, Worker, BaseComponent