Posts

Showing posts from March, 2019

select ends with killed in mysql

I ran a query in mysql and it hangs for a while and then I get killed as a response. mysql> select * from usagehistory; Killed SHELL:~$ SHELL:~$ date Thu Mar 14 06:26:17 UTC 2019 SHELL:~$ Reason The mysql process/client itself runs out of memory and is terminated by the OS. I do not have a good view of the implementation, but it appears that mysql is trying something like pulling the whole table into memory to do the select *. You can use the --quick mysql option to not buffer the results in memory. I also found out that the data in table is around 2 GB and Memory in my jump-box is around 1 GB. Two more proofs that I see in my jump box (where mysql is run) system is: 1. I see OOM messages in syslog. root@ip-XXX-XXX-XXX-XXX:~# grep mysql /var/log/syslog | less Mar 14 06:25:40 ip-XXX-XXX-XXX-XXX kernel: [529731.301028] mysql invoked oom-killer: gfp_mask=0x24201ca, order=0, oom_score_adj=0 Mar 14 06:25:40 ip-XXX-XXX-XXX-XXX kernel: [529731.301032] mysql cpuset=/ mems

mysql is not using the mentioned foreign key constraint name

I faced a strange situation, so I thought to share it with you, in case someone else finds himself in similar situation. I added a column to an existing table in MySQL. I also added a foreign key constraint on that column. So what is strange about that. Let me show you. First of all let me display the original structure of the table. mysql> SHOW CREATE TABLE T_DEVICE_RESULTANTSTATE\G *************************** 1. row *************************** Table: T_DEVICE_RESULTANTSTATE Create Table: CREATE TABLE `t_device_resultantstate` ( `RESULTANTSTATEID` int(11) NOT NULL AUTO_INCREMENT, `RESULTANTSTATE` blob, `DEVICEID` int(11) NOT NULL, `CREATEDBY` varchar(50) NOT NULL DEFAULT 'ADMIN', `CREATEDATE` datetime DEFAULT NULL, `MODIFIEDBY` varchar(50) NOT NULL DEFAULT 'ADMIN', `MODIFIEDDATE` datetime DEFAULT NULL, PRIMARY KEY (`RESULTANTSTATEID`), KEY `FK_T_DEVICE_RESULTANT_STATE_T_DEVICE` (`DEVICEID`), CONSTRAINT `FK_T_DEVICE_RESULTANT_STAT

A simple yet effective change password UI

Image
I believe that most of us had faced this situation which I am going to mention. Say you have an account for an online service. You visit their website, Login and found a message that your password will expire in 5 days, Change Password or Continue. You decided to change your password. A new page opens up asking for current and new password. Apart from that, the page also mentions some policy that you must adhere to in order to change your password. You enter your current password, new password, confirm password and press Submit. But you get surprised when you see "Your new password does not matches the required criteria" and you have no information that what goes wrong. But I saw a eye catching solution on Amazon Web Service website, so I thought of sharing it with you all. What they do is, when you key in your new password, they will tick mark the password policy that you have passed. They handle your key deletes as well. These little little things makes one s

Errors and Exceptions in Python

There are two kinds of errors in Python: syntax error and exceptions. Syntax Error Syntax errors are the errors that are caused by not following the proper structure (syntax) of the language. They are also known as parsing error. When you forget a colon at the end of a line, accidentally add one space too many when indenting under an if statement, or forget a parenthesis, you will encounter a syntax error. This means that Python couldn’t figure out how to read your program. This is similar to forgetting punctuation in English.  def some_function() msg = "hello, world!" print(msg) return msg The above function definition has two issues with syntax. First one is that the function definition is missing a colon (:) at the end. The second one is that the lines in the function definition do not all have the same indentation ( IndentationError ). Exceptions Even if a statement or expression is syntactically correct, it may cause an error when an attempt i

Identifiers and Keywords in Python

Python Identifier is the name we give to identify a variable, function, class, module or any other object. That means whenever we want to give an entity a name, that's called identifier. Think of this as we are identified by our names. Without names it is not possible to reference a person from a group of people in a room. Remember that identifier belongs to a namespace. Namespace is like family in real world. Hence two identifier with same name can be used independently in your program on a condition that they must belong to different namespace. Module introduce namespace in Python.  Rules for writing Identifiers 1. Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore (_). Identifiers like myClass, var_1 and print_this_to_screen, are all valid example. 2. An identifier cannot start with a digit. 1variable is invalid, but variable1 is perfectly fine. 3. Keywords cannot be used as identifiers. 4. We cannot
Back To Top