'Code Muri'에 해당되는 글 690건

  1. 2014.06.10 Difference between bin and sbin
  2. 2014.06.10 Shame and ashamed
  3. 2014.06.10 Memory Structure
  4. 2014.06.08 Binary Portablity
  5. 2014.06.08 On behalf of
  6. 2014.06.08 Dirty Read, Non-Repeatable Read and Phantom row
  7. 2014.06.06 Check where the data directory is on MySQL
  8. 2014.06.06 Use explain
  9. 2014.06.03 [Fiddler] WCF Binary Message Inspector
  10. 2014.06.02 Knife bootstrap failed only with "Connection closed by remote host"
  11. 2014.06.02 Linux SSH Session Timeout Setting
  12. 2014.05.24 PollingDuplex multiple mode timeouts demystified
  13. 2014.05.24 WCF Configuration Schema (web.config)
  14. 2014.05.22 List All Linux Commands
  15. 2014.05.20 WCF Tracing and Message Logging
  16. 2014.04.29 Dealing with those pesky WCF CommunicationException “NotFound” errors in Silverlight
  17. 2014.04.29 upload and download over 30 MB file between silverlight and wcf service
  18. 2014.01.07 How to: Build a Duplex Service for a Silverlight Client
  19. 2014.01.06 Forward Engineer SQL script using MySQL Workbench
  20. 2014.01.06 Create MySQL ERD using ERWin
2014. 6. 10. 08:10

Difference between bin and sbin

Remember this simply like sbin is system-bin and bin is user-bin.

For more detail:
http://linuxtroubleshoot.blogspot.kr/2011/03/difference-between-bin-vs-sbin-vs.html?m=1
2014. 6. 10. 02:23

Shame and ashamed

Today (Actually yesterday cause 12 am was passed) I feel very ashamed of failing the test. To express this feeling in English, I had confusion  about shame and ashamed.


I feel ashamed 


- I feel almost ashamed that I've been so lucky


I'm ashamed 


- I'm ashamed to say that I liked to her


Have you no shame?


You have shamed your family.



shame is noun and verb but ashamed is adjective. That's the point that I need to keep in mind.


* 종교 : Religion!


2014. 6. 10. 01:54

Memory Structure

The following diagram shows three different memory categories that server allocates.



 Server / Shared

  • Query Cache
  • Thread Cache 

 Storage Engine / Shared

  • Log buffer
  • Buffer pool

 Connection / Session

  • Sort buffer
  • Read buffer
  • Temporary table


Now check each item in more detail.


Query Cache


The query cache stores results of SELECT queries so that if the identical query is received in future, the results can be quickly returned.


Queries are examined in a case-sensitive manner, so


SELECT * FROM t


is different to 


select * from t


Comments are also considered and can make the queries differ, so


/* retry */ SELECT * FROM t


is different to


/* retry 2 */ SELECT * FROM t



Thread cache


By default, connection manager threads associate each client connection with a thread dedicated to it that handles authentication and request processing for that connection. Manager threads create a new thread when necessary but try to avoid doing so by consulting the thread cache first to see whether it contains a thread that can be used for the connection. When a connection ends, its thread is returned to the thread cache if the cache is not full.


The thread cache has a size determined by the thread_cache_size system variable. The default value is 0 (no caching), which causes a thread to be set up for each new connection and disposed of when the connection terminates.


(http://dev.mysql.com/doc/refman/5.5/en/connection-threads.html)


** I need to write more items that were not covered here **




2014. 6. 8. 18:20

Binary Portablity

Both MyISAM and InnoDB tablespaces are binary portable from one host to another if two conditions are met:


  • Both machines must use two's-complement integer arithmetic
  • Both machines must use IEEE floating-point format or else the tables must contain no floating-point columns (FLOAT or DOUBLE)

A third condition for InnoDB binary portability is that you should use lowercase names for tables and databases.

   ☞ This is because InnoDB stores these names internally (in its data dictionary) in lowercase on Windows. Using lowercase names allows binary portability between Windows and Unix, to force the use of lowercase names, you can put the following lines in an option file:


[mysqld]
lower_case_table_names=1


To sum up,


MyIsam 


  • Both machines must use two's-complement integer arithmetic
  • Both machines must use IEEE floating-point format or else the tables must contain no floating-point columns (FLOAT or DOUBLE)

InnoDB

  • Both machines must use two's-complement integer arithmetic
  • Both machines must use IEEE floating-point format or else the tables must contain no floating-point columns (FLOAT or DOUBLE)
  • Database and table names must use lowercase format


2014. 6. 8. 17:05

On behalf of

Implicitly set locks are locks set and released on behalf of the client, by the server.


On behalf of the department I would like to thank you all





~ 를 대신하여, ~를 대표하여

2014. 6. 8. 16:34

Dirty Read, Non-Repeatable Read and Phantom row

A dirty read occurs when a transaction is allowed to read data from a row that has been modified by another running transaction and not yet committed.


A non-repeatable read occurs, when during the course of a transaction, a row is retrieved twice and the values within the row differ between reads.


A phantom read occurs when, in the course of a transaction, two identical queries are executed, and the collection of rows returned by the second query is different from the first. The phantom reads anomaly is a special case of Non-repeatable reads.

2014. 6. 6. 23:50

Check where the data directory is on MySQL

The following command will show:

 

 

  mysql> show variables like 'datadir';
+---------------+---------------------------------------------+
| Variable_name | Value                                       |
+---------------+---------------------------------------------+
| datadir       | C:\ProgramData\MySQL\MySQL Server 5.6\data\ |
+---------------+---------------------------------------------+
1 row in set (0.00 sec)

 

2014. 6. 6. 23:28

Use explain

To get query execution plan, explain is used. but not just for this, explain is more useful to get the table information such as column list and its detail.


mysql> explain [schema_name].[table_name]


or


mysql > explain table_name


 mysql> explain world.city;

+-------------+----------+------+-----+---------+----------------+
| Field       | Type     | Null | Key | Default | Extra          |
+-------------+----------+------+-----+---------+----------------+
| ID          | int(11)  | NO   | PRI | NULL    | auto_increment |
| Name        | char(35) | NO   |     |         |                |
| CountryCode | char(3)  | NO   |     |         |                |
| District    | char(20) | NO   |     |         |                |
| Population  | int(11)  | NO   |     | 0       |                |
+-------------+----------+------+-----+---------+----------------+
5 rows in set (0.01 sec)


describe is same with this.


 mysql> describe information_schema.tables;

+-----------------+---------------------+------+-----+---------+-------+
| Field           | Type                | Null | Key | Default | Extra |
+-----------------+---------------------+------+-----+---------+-------+
| TABLE_CATALOG   | varchar(512)        | NO   |     |         |       |
| TABLE_SCHEMA    | varchar(64)         | NO   |     |         |       |
| TABLE_NAME      | varchar(64)         | NO   |     |         |       |
| TABLE_TYPE      | varchar(64)         | NO   |     |         |       |
| ENGINE          | varchar(64)         | YES  |     | NULL    |       |
| VERSION         | bigint(21) unsigned | YES  |     | NULL    |       |
| ROW_FORMAT      | varchar(10)         | YES  |     | NULL    |       |
| TABLE_ROWS      | bigint(21) unsigned | YES  |     | NULL    |       |
| AVG_ROW_LENGTH  | bigint(21) unsigned | YES  |     | NULL    |       |
| DATA_LENGTH     | bigint(21) unsigned | YES  |     | NULL    |       |
| MAX_DATA_LENGTH | bigint(21) unsigned | YES  |     | NULL    |       |
| INDEX_LENGTH    | bigint(21) unsigned | YES  |     | NULL    |       |
| DATA_FREE       | bigint(21) unsigned | YES  |     | NULL    |       |
| AUTO_INCREMENT  | bigint(21) unsigned | YES  |     | NULL    |       |
| CREATE_TIME     | datetime            | YES  |     | NULL    |       |
| UPDATE_TIME     | datetime            | YES  |     | NULL    |       |
| CHECK_TIME      | datetime            | YES  |     | NULL    |       |
| TABLE_COLLATION | varchar(32)         | YES  |     | NULL    |       |
| CHECKSUM        | bigint(21) unsigned | YES  |     | NULL    |       |
| CREATE_OPTIONS  | varchar(255)        | YES  |     | NULL    |       |
| TABLE_COMMENT   | varchar(2048)       | NO   |     |         |       |
+-----------------+---------------------+------+-----+---------+-------+
21 rows in set (0.01 sec)



2014. 6. 3. 07:30

[Fiddler] WCF Binary Message Inspector

Source: https://github.com/waf/WCF-Binary-Message-Inspector

 

 

BinaryMessageFiddlerExtension.dll

 

WCF Binary Message Inspector


This is a modification of the WCF Binary Message Inspector. It provides two notable enhancements:

Uses a collapsible tree view instead of a textarea to display the decoded WCF binary message.
Allows editing and reissuing of captured WCF binary messages (thanks to HofmaDresu)


Installation for Fiddler2

 

Copy the file BinaryMessageFiddlerExtension/bin/Release/BinaryMessageFiddlerExtension.dll (direct download) into C:\Program Files\Fiddler2\Inspectors and restart Fiddler.

 

Installation for Fiddler4 (Beta)

 

Copy the file BinaryMessageFiddlerExtension/bin/Release/BinaryMessageFiddlerExtension_Fiddler4.dll (direct download) into C:\Program Files\Fiddler2\Inspectors and restart Fiddler.

 

Tree View Usage

 

The tree view provides the following shortcuts:

Ctrl+c — Copy current node XML
Ctrl+Shift+c — Copy tree XML
Alt+→ — Expand node and all child nodes
Alt+← — Collapse node and all child nodes
Middle-click — Toggle expand/collapse of node and all child nodes


Edit Usage

 

Capture a WCF binary message
In the sessions list, right click on the message and choose "Unlock for editing"
Edit the request
Reissue the request using the toolbar or the session list context menu

2014. 6. 2. 06:56

Knife bootstrap failed only with "Connection closed by remote host"

Knife bootstrap beyond a jump host failed just showing following log:



 DEBUG: Adding xx.xx.xxx.xxx

DEBUG: establishing connection to 127.0.0.1:xxxxxx

DEBUG: connection established

INFO: negotiation protocol version

ERROR: Net::SSH:Disconnect: connection closed by remote host


To resolve this, change ssh config as below on the jump host:


sudo vi /etc/ssh/sshd_config


 AllowTcpForwading yes


And restart ssh service.

2014. 6. 2. 06:42

Linux SSH Session Timeout Setting

Our project faced a very weird problem that SSH.Net cannot get the exit event after 10 minutes. Though the command was finished, SSH.Net was waiting for its completion.


The reason was caused by the time-out of the ssh session. To increase this, set it as below.


sudo vi /etc/ssh/sshd_config


# 300 secons

ClientAliveInterval 300

# 300 * (12) MAX 1 HOUR

ClientAliveCountMax 12


$ sudo service ssh restart


After this, it worked well.

2014. 5. 24. 08:36

PollingDuplex multiple mode timeouts demystified

Source: http://blogs.msdn.com/b/silverlightws/archive/2010/07/16/pollingduplex-multiple-mode-timeouts-demystified.aspx


Written by   



The new MultipleMessagesPerPoll mode added to PollingDuplex in Silverlight 4, comes with some new timeouts , so I thought it would be useful to post a detailed description of how those work. Unfortunately this is not currently covered by our documentation, which is something we are looking to address in upcoming documentation refreshes.

This is a fairly advanced topic, and the default settings should work well for most customers, so only modify these if you are encountering an issue, and you are fairly confident a timeout is causing the problem. The information below applies only to the new multiple messages mode, which is activated by settingduplexMode="MultipleMessagesPerPoll" on the PollingDuplex binding or binding element.

One important thing in the text below is to differentiate between infrastructure messages (such as polls in this case) and application messages. Infrastructure messages such as polls (and poll responses) are not initiated by or surfaced to the user – they are just an implementation detail of the protocol. Application messages are messages that actually originated in the user code. They can be separated into client-to-server messages (“requests coming from client”) or server-to-client messages (“server responses to requests coming from client” and “requests coming from server”). There is no “client responses coming from server” because of the way polling works. I will try to stick to this terminology in the text below.

Most of the new timeouts live on the server. All class and member names refer to the server-side System.ServiceModel.PollingDuplex.dll that ships in the “Server” folder of the Silverlight SDK. Take a look at the following diagram for a visual explanation:




The diagram shows an incoming poll and the chunked response being returned containing application messages. The first server-to-client application message is greater than 16/32KB (16 for self-hosted PollingDuplex services, 32KB for IIS-hosted), so the chunked response is flushed and the message should arrive immediately at the client. The then client sends a smaller application messages, but the total size does not reach 16/32KB, so the chunked response is not flushed. To prevent the message from getting stuck, the chunked response will be flushed and closed when the MaxOutputDelay timer expires, and the message will then be delivered to the client. Then the client sends two application messages coming in from the client and the timeouts associated with those.

Here is a more detailed description of each timeout.

ServerPollTimeout

  • Set it here
    • System.ServiceModel.PollingDuplexHttpBinding.ServerPollTimeout
    • System.ServiceModel.Channels.PollingDuplexBindingElement.ServerPollTimeout
  • Definition: Time the server holds the poll request prior to sending an empty poll response to the client. After the first outgoing server-to-client application message (either server response to request coming from client or request coming from the server) gets sent, this timer stops being used, andMaxOutputDelay kicks in. Bound to the client dispatcher (HTTP request / response)
  • Default: 15 s

MaxOutputDelay

  • Set it here
    • System.ServiceModel.PollingDuplexHttpBinding.MaxOutputDelay
    • System.ServiceModel.Channels.PollingDuplexBindingElement.MaxOutputDelay
  • Definition: Time between the last outgoing server-to-client application message and the HTTP response being closed; it’s reset with each new outgoing message being dequeued. Closing the response ensures that all messages are flushed and no message will take longer than MaxOutputDelay to be delivered to the client. Bound to the client dispatcher.
  • Default: 200 ms

PollHeartbeatTimeout

  • Not settable – this is an internal property
  • Definition: Timer which is started when a poll response is sent to the client, and stopped when the next poll for that dispatcher is received. Bound to the client dispatcher. If the timeout is reached, all the channels bound to the dispatcher are faulted. This is how we determine if a client “is still there”.
  • Value: 4 * ServerPollTimeout + 30 s (after polling has started), 2 * ServerPollTimeout + 15 s (if server has not received the first poll from the client)

InactivityTimeout

  • Set it here
    • System.ServiceModel.PollingDuplexHttpBinding.InactivityTimeout
    • System.ServiceModel.Channels.PollingDuplexBindingElement.InactivityTimeout
  • Definition: Timer which is reset when an application messages is received by the channel. If the timeout is reached, the channel is faulted. Bound to the client session. Note that this not affected by polls, contrary to the way this same timeout behaves with infrastructure messages on other bindings (as described here). So effectively this is the same as ReceiveTimeout.
  • Default: 10 min

ReceiveTimeout

  • Set it here
    • System.ServiceModel.Channels.Binding.ReceiveTimeout
  • Definition: Timer which is reset when the ServiceModel layer pumps an application message from a PollingDuplex channel. If the timeout is reached, the channel is aborted. Infrastructure messages such as polls don’t affect this timeout. Bound to the client session (channel).
  • Default: 10 min

 

On the client side, we also have some timeouts that may be of interest. All class and member names below refer to the client-side System.ServiceModel.PollingDuplex.dll that ships in the “Client” folder of the Silverlight SDK.

ClientPollTimeout

InactivityTimeout

Hope this is useful.

2014. 5. 24. 07:30

WCF Configuration Schema (web.config)


The following link shows the detailed information about wcf web.config configuration. 


http://msdn.microsoft.com/en-us/library/ms731734(v=vs.110).aspx






The tip to search for msdn site, use "site:" option on Google.


site:http://msdn.microsoft.com/en-us wcf "<bind>" 



Additionally silverlight configuration schema site is as below:


http://msdn.microsoft.com/ko-kr/library/dd547083(v=vs.95).aspx

2014. 5. 22. 07:03

List All Linux Commands

Using compgen can list all available commands in Linux.

 

 

compgen -c 

 

Using grep command together, you can extract some command to find.

 

compgen -c | grep mysql 

 

 

To list all the bash shell aliases available,

 

compgen -a 

 

Reference: http://www.cyberciti.biz/open-source/command-line-hacks/compgen-linux-command/

 

2014. 5. 20. 05:56

WCF Tracing and Message Logging

Really I did ridiculous thing. 


Our system showed "Server too busy" exception so I wanted to trace the log messages of the WCF services. I followed lots of instructions for that. 



And the critical thing was as below:


  <sharedListeners>
    <add name="xml"
         type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="C:\logs\Traces.svclog" />
  </sharedListeners>


After restarting our service, I refreshed the windows explorer to check if the log file was created but it didn't. 


The reason was very simple. The log file couldn't be created if the destination folder does not exist. So only after creating the 'c:\logs' folder, my concern was removed.



MSDN offers the recommended settings for tracing and message logging

(http://msdn.microsoft.com/en-us/library/aa702726(v=vs.110).aspx)



  • Recommnded Settings for a Production Environment

<configuration>
 <system.diagnostics>
  <sources>
    <source name="System.ServiceModel"
            switchValue="Warning"
            propagateActivity="true" >
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
    <source name="myUserTraceSource"
            switchValue="Warning, ActivityTracing">
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add name="xml"
         type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="C:\logs\Traces.svclog" />
  </sharedListeners>
 </system.diagnostics>

<system.serviceModel>
  <diagnostics wmiProviderEnabled="true">
  </diagnostics>
 </system.serviceModel>
</configuration>

  • Recommended Settings for Deployment or Debugging
configuration>
 <system.diagnostics>
  <sources>
    <source name="System.ServiceModel"
            switchValue="Information, ActivityTracing"
            propagateActivity="true" >
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
    <source name="System.ServiceModel.MessageLogging">
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
    <source name="myUserTraceSource"
            switchValue="Information, ActivityTracing">
      <listeners>
        <add name="xml"/>
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add name="xml"
         type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="C:\logs\Traces.svclog" />
  </sharedListeners>
 </system.diagnostics>

 <system.serviceModel>
  <diagnostics wmiProviderEnabled="true">
      <messageLogging 
           logEntireMessage="true" 
           logMalformedMessages="true"
           logMessagesAtServiceLevel="true" 
           logMessagesAtTransportLevel="true"
           maxMessagesToLog="3000" 
       />
  </diagnostics>
 </system.serviceModel>
</configuration>

To see the logs, use the service trace viewer tool!
(C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SvcTraceViewer.exe)

(http://msdn.microsoft.com/en-us/library/ms732023(v=vs.110).aspx)



2014. 4. 29. 02:51

Dealing with those pesky WCF CommunicationException “NotFound” errors in Silverlight

The following links are very helpful to figure out the problem that shows "NotFound" errors in Silverlight.



Dealing with those pesky WCF CommunicationException “NotFound” errors in Silverlight


http://blogs.msdn.com/b/silverlightws/archive/2010/04/15/dealing-with-those-pesky-wcf-communicationexception-notfound-errors-in-silverlight.aspx


Creating and Handling Faults in Silverlight

(http://msdn.microsoft.com/en-us/library/ee844556(v=VS.95).aspx)


Configuring WCF SOAP Faults for Use with Silverlight Clients

Receiving SOAP faults is not supported in the default configuration, due to Web browser limitations. When the service does send a fault, an exception is thrown on the client, but it does not specify any information about the fault that has occurred. However, there are two ways to enable SOAP fault consumption:

  • Modify the HTTP status code: You can modify your service to return SOAP faults with an HTTP status code of 200, Silverlight 4 so that faults will be processed successfully. How to do this is outlined below. Note that this will make the service non-compliant with the SOAP protocol, because SOAP requires a response code in the 400 or 500 range for faults. If the service is a WCF service, you can create an endpoint behavior that plugs in a message inspector that changes the status code to 200. Then you can create an endpoint specifically for Silverlight consumption, and apply the behavior there. Your other endpoints will still remain SOAP-compliant. 

  • Use the alternative client HTTP stack: You can register an alternative HTTP stack by using the RegisterPrefix method. See below for an outline of how to do this. Silverlight 4 provides the option of using a client HTTP stack which, unlike the default browser HTTP stack, allows you to process SOAP-compliant fault messages. However, a potential problem of switching to the alternative HTTP stack is that information stored by the browser (such as authentication cookies) will no longer be available to Silverlight, and thus certain scenarios involving secure services might stop working, or require additional code to work. For more information, see HttpCookieContainerBindingElement.


2014. 4. 29. 02:39

upload and download over 30 MB file between silverlight and wcf service

Recently My project members and I are suffering from the problem that cannot upload and download over 30 MB file between silverlight and wcf service.


I googled lots of things and applied the suggestions but anything did not resolve our issue.


With this trouble remained I cannot sleep well so I'm writing this article now.


I searched more webs to find any hint to help us. Following sites can be helpful but the result will be known tomorrow.


http://ajaxuploader.com/large-file-upload-iis-debug.htm


This site suggests very good guide lines as below: 


1. Required

IIS7 - maxAllowedContentLength

IIS6 - maxRequestLength


2. Microsoft URL Scan

C:\WINDOWS\system32\inetsrv\urlscan\UrlScan.ini

MaxAllowedContentLength


3. File upload debug file


debug-upload.zip



http://ajaxuploader.com/large-file-upload-iis-asp-net.htm


This sites shows the required configuration for IIS7


1. Modify the maxAllowedContentLength setting in the web.config


<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="2147483648" />
    </requestFiltering>
  </security>

</system.webServer> 


=> 2147483648 - 2 GB in size

2. Edit the request filtering feature settings and the request limits using IIS manager

  • Open IIS Manager.
  • Select the website that you want to configure.
  • Make sure you are in Features View per the button at the bottom of the manager.
  • Select Requests Filtering and open it by double-clicking the icon. The Request Filtering pane displays.
  • From the Actions pane on the right hand side of the screen click Edit Feature Settings... link. The Edit Request Filtering Settings window displays.
  • In the Request Limits section, enter the appropriate Maximum allowed content length (Bytes) and then click the OK button.
  • Restart IIS.


3. Manually edit the ApplicationHost.config file



  • Click Start. In the Start Search box, type Notepad. Right-click Notepad, and then click Run as administrator.
  • On the File menu, click Open. In the File name box, type %windir%\system32\inetsrv\config\applicationhost.config, and then click Open.
  • In the ApplicationHost.config file, locate the <requestLimits> node.
  • Remove the maxAllowedContentLength property. Or, add a value that matches the size of the Content-Length header that the client sends as part of the request. By default, the value of the maxAllowedContentLength property is 30000000. 

    For example, modify the following configuration data inside the <requestFiltering> section.

    <requestLimits maxAllowedContentLength ="<length>" />
  • Save the ApplicationHost.config file.


Finally to resolve this, we developed upload/download feature with new way: duplex communication on download and upload partitioning.


But this information is worth keeping in mind.

2014. 1. 7. 02:24

How to: Build a Duplex Service for a Silverlight Client


Do not forget to call Close (CloseAsync in case of Silverlight) of Proxy Service Client!



sl4_wcf_nettcp_duplex_article.zip



References:




2014. 1. 6. 06:43

Forward Engineer SQL script using MySQL Workbench

MySQL Workbench had nice feature to make SQL script to create a schema from existing database but it was not easy to find where it is.


1. Start MySQL Workbench


2. Select "Create EER Model From Existing Database" in the 'Data Modeling' section.

  (If you already have existing EER model, select it)





 * Enter required information and select Schema to reverse engineer


3. If EER Diagram is opened without any problem, Select "File > Export > Forward Engineer SQL CREATE Script..." like the following :





4. Select any option as you wish from the dialog and proceed the steps until the finish button is shown like the following. 





5. It's the SQL script we want.




2014. 1. 6. 06:09

Create MySQL ERD using ERWin

Visit the following site to get more detail:


http://mkyojung.wordpress.com/2012/09/21/erwin%EC%97%90%EC%84%9C-mysql-erd-%EC%83%9D%EC%84%B1reverse-engineering/