I use this function a lot. It really helps me avoid using other secondary tables with `CONCAT`.
Today tho, I found it wasn't giving me the expected result. It was trimming or cutting the total length of the group concatenation. I found that this is due to a default parameter on MySQL `group_concat_max_len` which is by default 1024.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Quality
Anya is LIVE right now
FREE
Free to watch ⢠No registration required ⢠HD streaming
I ran into this error when I managed a MySQLÂ âmanuallyâ on EC2, however, when I migrated to an RDS instance, I assumed everything would work out of the box with no issues whatsoever.
Until we realised that from time to time we would have âMySQL has gone awayâ errors.
One of the reasons this can happen is that an open connection has gone âcoldâ and because of inactivity has closed itself without the app noticing.
This was happening to us on some workers that did not have much load, so we just had to close the MySQL connection after a messages was processed (ack) and problem sorted.
Create a new filter to match the host on the desired entries
Create a new action so we check the X-Forwarded-For header
Create a new jail for it
This is the filter:
[Definition]
# Option: Â failregex
# Notes.: Â Regexp to catch a generic call from an IP address.
# Values: Â TEXT
#
failregex = ^<HOST> -.*"GET url_to_check.*$
# Option: Â ignoreregex
# Notes.: Â regex to ignore. If this regex matches, the line is ignored.
# Values: Â TEXT
#
ignoreregex =
The action:
[INCLUDES]
before = iptables-common.conf
[Definition]
# Option: Â actionstart
# Notes.: Â command executed once at the start of Fail2Ban.
# Values: Â CMD
#
actionstart = <iptables> -N f2b-<name>
      <iptables> -A f2b-<name> -j <returntype>
      <iptables> -I <chain> -p tcp -m multiport --dports 80,443 -j f2b-<name>
# Option: Â actionstop
# Notes.: Â command executed once at the end of Fail2Ban
# Values: Â CMD
#
actionstop = <iptables> -D <chain> -p tcp -m multiport --dports 80,443 -j f2b-<name>
      <iptables> -F f2b-<name>
      <iptables> -X f2b-<name>
# Option: Â actioncheck
# Notes.: Â command executed once before each actionban command
# Values: Â CMD
#
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \t]'
# Option: Â actionban
# Notes.: Â command executed when banning an IP. Take care that the
# Â Â Â Â Â command is executed with Fail2Ban user rights.
# Tags: Â Â See jail.conf(5) man page
# Values: Â CMD
#
actionban = <iptables> -I f2b-<name> 1 -p tcp -m multiport --dports 80,443 -m string --algo bm --string 'X-Forwarded-For: <ip>' -j <blocktype>
# Option: Â actionunban
# Notes.: Â command executed when unbanning an IP. Take care that the
# Â Â Â Â Â command is executed with Fail2Ban user rights.
# Tags: Â Â See jail.conf(5) man page
# Values: Â CMD
#
actionunban = <iptables> -D f2b-<name> -p tcp -m multiport --dports 80,443 -m string --algo bm --string 'X-Forwarded-For: <ip>' -j <blocktype>
[Init]
Note I hardcoded both the ports and the protocol. Made it so because, for some reason, I wasnât getting passed the proper values in their variables.
And finally the jail
enabled = true
port   = http,https
filter  = <filter name>
action = <action name>
logpath = <log path>
findtime = <seconds to watch>
bantime  = <ban time>
maxretry = <max number of attempts>
I had a âsmallâ DB that was basically logging different stuff. When I start new structures that are not 100% defined, I tend to save raw data so I can recover any extra filed in case I needed it in the future. After some time, once the domain has been validated and Iâm saving the right fields, I usually remove that raw field.
Now that I had validated the domain (After 2M rows), I decided to remove the raw content for the first 1.9M rows (lets leave it for the last 100K). I saw that the entire table was around 32GB, so I would expect a significant drop in size.
I performed these deletes:
UPDATE foo SET raw = null;
As simple as that. But, hey! What happened? Rather than freeing up space, I actually ended up using more!
I then read about how to free this space on InnoDB, and apparently MySQL keeps the space alloc for its own use, but handles it internally. So eventually that space would be used with future inserts.
However, when you have 10GB free, Iâd rather flush that extra space.
For doing so, youâd run
OPTIMIZE TABLE foo;
But, would you run this directly in production? I created a slave in RDS (just to test it out). The replica took 49 minutes to create. Then upgraded the slave to master, and executed the query.
This is what I got after an hour:
Yes! All good!
Also, after MySQL 5.7.4, the Optimize query does not lock the table, so you can run this in production with no downtime (there may be a tiny lock, but should be fine).
Tuesday afternoon, the server just stopped accepting requests⌠A fast ssh and a service restart fixed the issue.
Now lets check the logs.
Ok⌠nothing unusual here. But I start noticing that after some certain requests, everything is returning 499 status code or 50X. I eventually realise that everytime Mandrill webhooks are being triggered, this happens, so I checked the Mandrill webhook log:
There you go⌠From sending 1-10 events per request, Mandrill suddenly stopped for 10 days, and then sent 600. This explains those ârandomâ 5 minute downtime emails I had a few weeks ago⌠The server was being maxed out.
First approach was actually an accident, but we simply queued every event in redis. Now having the site safe again, I made an asynchronous task with RabbitMQ for processing these events. Problem fixed! Just had 33 thousand events to process now in Redis :) Eventually switched from a Redis queue to directly publishing these events in Rabbit.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Quality
Anya is LIVE right now
FREE
Free to watch ⢠No registration required ⢠HD streaming
I ran into a problem:
Displaying 60 elements on an ng-repeat caused the browser to freeze for several seconds.
I went through the code and couldnât find any issue at all on the computational orders that I was dealing with. So I went for the easy hack: paginate and show 10 at a time. Does this help?
This fixed my issue but I felt like it was not a âgood enoughâ approach: Lets really fix this.
So I started profiling the CPU of the JS usage with Chrome: ok, my JS is minified, lets undo that step.
Changed my Gruntfile.js so it took the non .min files and ran into this:
Pretty clear the issue was with âtriggerAnimationStartâ. Mhhh... âanimationâ, huh? I do not use any animation in this page:
/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:25
const builder = require('./builder');
^^^^^
[launcher] Process exited with error code 1
SyntaxError: Use of const in strict mode.
  at Module._compile (module.js:439:25)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/usr/local/lib/node_modules/protractor/built/protractor.js:3:17)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
Can be fixed by either downgrading protractor from version 3 to version 2. Or you can also upgrade nodejs from version 0.xx to version 4.
So on the previous post I mentioned that ElasticSearch ended up being corrupted due to the forced shut-down. It seems like RabbitMQ also died but I did not notice this because we use RabbitMQ for empowering PHP with async capabilities.
I ended up in a gist where I found how to fixÂ
rm -fr /var/lib/rabbitmq/mnesia/*
service rabbitmq-server start
Again, in my case RabbitMQ did not hold any vital nor critical information, just populated stuff that I can recover from MySQL.
What to do when ElasticSearch wonât start due to corrupted indexes
My local development VM crashed yesterday while it was booting - I was afraid it may have broken something and those fears were confirmed when I restarted my machine: ElasticSearch indexes were corrupted.
I tried to start the elasticsearch service, but couldnât - threw some exceptions mentioning âError injecting constructorâ. Searched a bit on google and all the solutions I found were to âcurl -XDELETE ...â. I was wondering how can I do that if the service is down! I canât query the API!
Looked into the ElasticSearch documentation for the routes where the indexes where located:
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Quality
Anya is LIVE right now
FREE
Free to watch ⢠No registration required ⢠HD streaming
Its been a while since my last post. Its not that I havenât learnt a thing, its just that I havenât had time to write about it :)
Getting into what matters; Iâve made quite a huge reafactor on the JS side today. I wanted to have some error logging in the front end, so I searched a bit about it and found that there are some providers that give you logging platforms for these type of errors, but they are pretty expensive for what they do.
So I decided to track errors myself:
window.onerror
This made it! Added a handler for errors and that was it.
<script type="text/javascript">
     window.onerror = function(m,u,l){try{var i=new Image();var f=encodeURIComponent;i.src='/_e?m='+f(m)+'&u='+f(u)+'&l='+f(l);}catch(e){/* :( */}}; </script>
This requests for an âimageâ (it actually loads a controller) and that way I track the data Iâm sending as a get parameter. Cool thing about this is that I can also get user context information because cookies are sent too.
I was trying to run only the tests that failed on my last run, as I have some that need to wait for some web hooks to trigger and those passed⌠So, how do I get it to just run the tests that failed?
It seems you canât.
But theres an option to filter which tests you want to run: by class or by method.
If you want to check if you can upgrade a package, you can do several things:
apt-cache policy <package>
This will tell you the difference between your package and the repository one:
$ apt-cache policy php5
php5:
 Installed: 5.5.9+dfsg-1ubuntu4.4
 Candidate: 5.5.9+dfsg-1ubuntu4.14
 Version table:
  5.5.9+dfsg-1ubuntu4.14 0
    500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
    500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
*** 5.5.9+dfsg-1ubuntu4.4 0
    100 /var/lib/dpkg/status
  5.5.9+dfsg-1ubuntu4 0
    500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
If you wanna simulate what would happen if you upgraded/installed a package:
So this is not really something Iâve learnt today, but Iâm changing my SSD drive, from 250GB to 500GB - Tired of having to remove files every week. Iâve noticed tho that docker instances are incredibly small in comparison to my vagran machines.
Iâm getting the Samsung EVO 850 500GB SSD. And if someone is doing this for a Mac, I recommend getting the adapter for changing the SuperDrive and replacing it with the old HDD.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Quality
Anya is LIVE right now
FREE
Free to watch ⢠No registration required ⢠HD streaming
Installing SSL in Amazon ELBÂ should be easy, but it cannot be.
In this post, Iâll be talking about Comodo Essential SSL, as its the one I installed.
Everything is straight forward (Follow NCZOnlineâs tutorial) until you get to the chain (which Amazon say is not required, but if you donât use it youâll end up having bad UX in mobile and randomly in some browsers).
Iâll copy the NCZOnline tutorial up to the point where you have to do something special.
1 - Convert your key (Just copy the RSA stuff)
openssl rsa -in host.key -text
2 - Convert your certificate
openssl x509 -inform PEM -in certificate.crt
3 - Chain stuff
Now here youâll notice that Comodo gives you the CA crt with the following order: Root +Â AddTrustCA +Â DomainValidationSecureServerCA.
When importing these crts as PEM into Amazon, I tried different combinations (vaguely guided by Amazons error messages), and ended up finding that the right order for Amazon is:Â DomainValidationSecureServerCA +Â AddTrustCA + Root. Exactly the opposite order of what Comodo gives you.
So at the end, youâll have to PEM them with something like:
And also, I had ONE chain file, with the three certificates appended, so had to slice the file in three, then inspect each of them and identify which one was what, and finally do the conversion. Pasted in Amazon, and worked.