SyntaxHighlighter

2014年9月25日木曜日

tarコマンドの末尾についてるハイフン

おはようございます。

他人が書いたbashスクリプトを見てたら、

tar -cf ${tarFile} -T -

っていうコマンド発行してるところがあって、浅学な私は「なんだこのゴミ…」って思ってしまったわけです。

でも実際動いてるコードだからなぁと思って調べてみると、「アーカイブするデータを標準入力から受け取る」っていうオプションだったのです。

なんでこんな仕様にしたんだろ… 理由があるのかも知れないけど。

2014年9月4日木曜日

DBD driver has not implemented the AutoCommit attribute at なんじゃこりゃー

こんばんは。

CentOS + mysql + perlの環境です。

3000000件以上のレコードをdeleteする処理がありまして、トランザクション使って削除しようとしてました。まだ開発段階のコードです。

トランザクション開始して、delete、delete、delete deleteと4回めのdelete処理(1回めは1件、2回めは30件くらい、3回めは3000件くらい、4回めは3000000件くらい)を行ったら4回めでエラーになった。

DBD driver has not implemented the AutoCommit attribute at ほげほげ

と表示されている。なんじゃこれ?とググるが有用な日本語記事は1件しかない。英語も引っかかるけど、なんかピンと来ない感じ。

同時刻の/var/lib/mysql/hostname.errのログを見ると、mysqlが落ちて、mysql_safeが再起動したみたいな。

140904 18:05:27 mysqld_safe Number of processes running now: 0
140904 18:05:27 mysqld_safe mysqld restarted
2014-09-04 18:05:30 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-09-04 18:05:31 21675 [Note] Plugin 'FEDERATED' is disabled.
2014-09-04 18:05:31 21675 [Note] InnoDB: The InnoDB memory heap is disabled
2014-09-04 18:05:31 21675 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
2014-09-04 18:05:31 21675 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-09-04 18:05:31 21675 [Note] InnoDB: Using Linux native AIO
2014-09-04 18:05:31 21675 [Note] InnoDB: Not using CPU crc32 instructions
2014-09-04 18:05:31 21675 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2014-09-04 18:05:31 21675 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-09-04 18:05:31 21675 [Note] InnoDB: Using Linux native AIO
2014-09-04 18:05:31 21675 [Note] InnoDB: Not using CPU crc32 instructions
2014-09-04 18:05:31 21675 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-09-04 18:05:31 21675 [Note] InnoDB: Completed initialization of buffer pool
2014-09-04 18:05:32 21675 [Note] InnoDB: Highest supported file format is Barracuda.
2014-09-04 18:05:35 21675 [Note] InnoDB: The log sequence numbers 23781084774 and 23781084774 in ibdata files do not match the log sequence number 24879295225 in the ib_logfiles!
2014-09-04 18:05:35 21675 [Note] InnoDB: Database was not shutdown normally!
2014-09-04 18:05:35 21675 [Note] InnoDB: Starting crash recovery.
2014-09-04 18:05:35 21675 [Note] InnoDB: Reading tablespace information from the .ibd files...
2014-09-04 18:05:38 21675 [Note] InnoDB: Restoring possible half-written data pages
2014-09-04 18:05:38 21675 [Note] InnoDB: from the doublewrite buffer...
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 3033 row operations to undo
InnoDB: Trx id counter is 3525120
2014-09-04 18:05:41 21675 [Note] InnoDB: 128 rollback segment(s) are active.
InnoDB: Starting in background the rollback of uncommitted transactions
2014-09-04 18:05:41 8e985b70  InnoDB: Rolling back trx with id 3524767, 3033 rows to undo

InnoDB: Progress in percents: 12014-09-04 18:05:41 21675 [Note] InnoDB: Waiting for purge to start
2014-09-04 18:05:41 21675 [Note] InnoDB: 5.6.14 started; log sequence number 24879295225
 22014-09-04 18:05:42 21675 [Note] Server hostname (bind-address): '*'; port: 3306
2014-09-04 18:05:42 21675 [Note] IPv6 is available.
2014-09-04 18:05:42 21675 [Note]   - '::' resolves to '::';
2014-09-04 18:05:42 21675 [Note] Server socket created on IP: '::'.
 32014-09-04 18:05:42 21675 [Note] Event Scheduler: Loaded 0 events
2014-09-04 18:05:43 21675 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.14'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 1002014-09-04 18:06:22 21675 [Note] InnoDB: Rollback of trx with id 3524767 completed
2014-09-04 18:06:22 8e985b70  InnoDB: Rollback of non-prepared transactions completed
2014-09-04 18:14:34 21675 [Warning] IP address '10.0.2.2' could not be resolved: Name or service not known
2014-09-04 18:17:18 21675 [Note] /usr/sbin/mysqld: Normal shutdown


んー、、、 まぁmysqldがリスタートされて、トランザクションはRollbackされたんね。うん。

その後、同じことをやってもエラーはおきず。順調にコミットされる。

mysqldが腐ってた、ということなんだろうけど、なんで腐ったんじゃか。今はわかりません。






2014年9月1日月曜日

Vagrantで already locked for a session が出てあせった

おはようございます。

vagrantのVMをまるごとバックアップしようと思って、vagrant haltしたら、いつも終了するはずの時間が経過しても終わらない…

よく見たら、

C:\VM\hoge>vagrant halt
[default] Attempting graceful shutdown of VM...

の後に、Force shutdown的なメッセージが出てるじゃないですか、やだなあ。

で、しびれを切らしてctrl-c。vagrant statusすると、stoppingって出てる。普通に終了すると、

Current machine states:
default                   poweroff (virtualbox)


って出るはずだから、中途半端で終わってることは間違いない。ひぃー。

おそるおそるvagrant upしてみると、、、赤い字がでたあああ∑(´Д`;)

Vagrant: Stderr: VBoxManage: error: The machine ‘hogehoge’ is already locked for a session (or being unlocked)


うわあああ、と思ってググる。ググり方が悪くて英語のサイトしか出てこないけど…、ん?OS再起動すれば良いみたいなことが書いてあった。OS再起動。

で、見事に起動しました。

ポートの設定当たりでゴミが残ってたんですかねえ(´ー`) ふぅ